Remix.run Logo
▲ phonon 5 hours ago

https://github.com/facebookincubator/cinderx might be a better approach.

▲O5vYtytb 4 hours ago | parent [-]

CinderX isn't generally faster unless you use "Static Python" which is a major change in how programs are written compared to typical python code.

▲phonon 3 hours ago | parent [-]

Out of the box it's comparable to the current JIT, but yes, major gains are only possible with at least type annotations. But that may be the only real way forward for a JIT implementation for CPython with the ability to gradually speed up slow parts of large programs.

https://facebookincubator.github.io/cinderx/#performance

▲hedgehog 2 hours ago | parent [-]

I did some experiments translating a typed subset of Python to C for small system use, certain features like lists of primitive types, generators and comprehensions, frozendict, simple classes, generic functions, etc, map with little or no cost but are so much cleaner than the equivalent code in plain C. You also get to write test harnesses using all the tools available to full Python. The main issue is unsurprisingly memory management, Obj-C / Swift style automatic reference counting works but has drawbacks, and it gets much more complicated if you want to mix the static and CPython code.

The static + AOT approach has a lot of promise now that type annotations are widely adopted, predictable behavior and good performance on code that is mostly idiomatic Python seem like a good alternative in many situations to the weight of Rust.

▲phonon 29 minutes ago | parent [-]

Yes, exactly. If you can get a 2-3x speedup in CPython just with type annotations, and then a possible additional 2-3x by dropping down to "Static Python," that may be an overall near optimal solution for the ecosystem, all things considered.