shish/rosettaboy

`run_mypyc.sh` does not really use `mypyc`?

will-ca opened this issue · 3 comments

Since mypyc compiles modules, it probably needs to be run on all src/*.py files. Doing only mypyc main.py probably only compiles the entrypoint.

E.G.:

  • If you delete one of the files like src/cpu.py, mypyc still compiles successfully but ModuleNotFoundErrors at run time. This presumably shows it's still trying to import the slow, uncompiled cpu.py.
  • Looks like you can open build/__native.c to read the generated code. It's not pretty, but it doesn't look like it's doing anything more than importing the uncompiled modules, running them, and exiting.
  • Docs show separately specifying all modules that you want to compile.

No idea if it will even work if you try to compile everything— E.G. To get it running in Cython, I had to separate all the exec()-generated code in cpu.py out into actual code instead (....Which I see has been removed and made obsolete literally the day after I did that.... Gosh dangit!)— If that's needed for MyPy too, I can post that as a starting point.

shish commented

This does appear to be correct, and some of the modules are using features that mypyc doesn't support D:

shish commented

Looks like with things marked as Final, it is only cpu.py's use of match that isn't supported, but support for match was added very recently, so if we can get the latest build of mypyc hopefully that would work?

python/mypy#13953

shish commented

Using the latest version of mypy from git, this now works, for an ~8x speedup \o/