-
Notifications
You must be signed in to change notification settings - Fork 1
Description
The Camelot maintainers have helpfully alerted me to the existence of mypyc.
Quickly testing it reveals that even without any code changes it can greatly speed up some code like the CCITT decoder that honestly has no business being written in Python (but I really like having no dependencies and an uncomplicated build...), even without any further optimization (a couple of code fixes though):
$ time pytest -k image tests/test_cli.py
real 22m3.838s
user 21m48.409s
sys 0m11.187s
$ mypyc playa/ccitt.py playa/lzw.py playa/image.py
$ time pytest -k image tests/test_cli.py
real 16m42.523s
user 16m25.405s
sys 0m16.364sCurrently mypyc can't be used everywhere and needs to be used with care, notably because of the use of introspection in the interpreter and generator expressions all over the place. Notably we need to fix a few things so that playa.pdftypes can be compiled, and this will make a really big difference.
The code can also be optimized for mypyc just by adding mypy-extensions types like i32 in strategic places.
It also appears that this exists: https://github.com/ofek/hatch-mypyc