Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run_mypyc.sh does not really use mypyc? #78

Closed
will-ca opened this issue Dec 5, 2022 · 3 comments
Closed

run_mypyc.sh does not really use mypyc? #78

will-ca opened this issue Dec 5, 2022 · 3 comments
Labels
python Python-specific

Comments

@will-ca
Copy link
Contributor

will-ca commented Dec 5, 2022

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
Copy link
Owner

shish commented Dec 5, 2022

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

shish added a commit that referenced this issue Dec 5, 2022
@shish
Copy link
Owner

shish commented Dec 5, 2022

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 added a commit that referenced this issue Dec 5, 2022
shish added a commit that referenced this issue Dec 5, 2022
shish added a commit that referenced this issue Dec 5, 2022
shish added a commit that referenced this issue Dec 5, 2022
will-ca added a commit to will-ca/rosettaboy that referenced this issue Dec 6, 2022
Squashed commit of the following:

commit c167245
Author: Shish <shish@shishnet.org>
Date:   Tue Dec 6 01:45:06 2022 +0000

    [utils] python3.11 as default in docker

commit d520b55
Author: Shish <shish@shishnet.org>
Date:   Mon Dec 5 23:54:10 2022 +0000

    [all] use /usr/bin/env bash instead of /bin/bash

commit 058f687
Author: Intralexical <37680486+will-ca@users.noreply.github.com>
Date:   Mon Dec 5 23:44:14 2022 +0000

    [rs] Add `shell.nix`.

commit 6d2550b
Author: Intralexical <37680486+will-ca@users.noreply.github.com>
Date:   Mon Dec 5 23:44:08 2022 +0000

    [py] Add `shell.nix`.

commit c319ba5
Author: Intralexical <37680486+will-ca@users.noreply.github.com>
Date:   Mon Dec 5 23:44:02 2022 +0000

    [php] Add `shell.nix`.

commit b28b42b
Author: Intralexical <37680486+will-ca@users.noreply.github.com>
Date:   Mon Dec 5 23:43:56 2022 +0000

    [nim] Add `shell.nix`.

commit a96097f
Author: Intralexical <37680486+will-ca@users.noreply.github.com>
Date:   Mon Dec 5 23:43:50 2022 +0000

    [go] Add `shell.nix`.

commit e6e74d6
Author: Intralexical <37680486+will-ca@users.noreply.github.com>
Date:   Mon Dec 5 23:43:43 2022 +0000

    [cpp] Add `shell.nix`.

commit 177f282
Author: Shish <shish@shishnet.org>
Date:   Mon Dec 5 13:37:59 2022 +0000

    [py] pass mypy --strict checks, see shish#78

commit d341b1c
Author: Shish <shish@shishnet.org>
Date:   Mon Dec 5 12:31:48 2022 +0000

    [py] mark static enums as Final, see shish#78
@shish
Copy link
Owner

shish commented Dec 10, 2022

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

@shish shish closed this as completed Dec 10, 2022
@shish shish added the python Python-specific label Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Python-specific
Projects
None yet
Development

No branches or pull requests

2 participants