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

But that is precisely what mypyc[0] is doing!

It is part of mypy, and it compiles type-valid python files to cpython binary extensions, and takes advantage of a lot of shortcuts available to cut execution time. It is still a bit early to advocate for its use everywhere, and has it drawbacks (extensions compiled with mypyc will also typecheck the inputs and outputs of the module at runtime, which is great for improving code quality and validity of the annotations, but also means you may get TypeErrors in production if you hit a bad edge case).

If there is no shortcut it will fallback to normal, slow, python performance, with some smallish benefits (e.g. vtables for attribute lookups, no parsing time, etc).

[0] https://mypyc.readthedocs.io/



That's really neat, I hadn't heard of mypyc!

How does it compare to Nuitka? https://nuitka.net


I have not ran benchmarks, I would expect Nuitka to be more mature and optimized, but I really like the idea of having it bound with the type-checker.




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

Search: