Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can someone ELI5 how this works as an extension module ? Is it possible to do a similar thing with pypy ?


I haven't read their source code, but the API extensions defined in PEP 523[1] lets extension modules (written in C or C level languages) to replace the default interpreter loop[2] with a custom one. I suspect they're using this mechanism to replace the default interpreter loop with their custom one when the module is imported and the enable function is called.

[1]: https://peps.python.org/pep-0523/ [2]: https://github.com/python/cpython/blob/main/Python/ceval.c


You inspired me to take a look at their code.

The autoload module at https://github.com/pyston/pyston/blob/96d5d33186b81f96ce3d9a... just calls:

    __import__("pyston_lite").enable()
It took some digging, but it looks like that enable() method is defined in the C code here: https://github.com/pyston/pyston/blob/96d5d33186b81f96ce3d9a...

It calls jit_start() which I think is here and does more of the interesting work: https://github.com/pyston/pyston/blob/69b190003f14dfd2f6d276...


> Is it possible to do a similar thing with pypy ?

The predecessor of Pypy is called Psyco http://psyco.sourceforge.net/

To enable JIT in Python2.x, simply `import psyco; psyco.full()`

It was fun while it lasted.

For Pypy3, check out https://github.com/fijal/jitpy




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: