-
Notifications
You must be signed in to change notification settings - Fork 1
Sync mypy including the stubs #14
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
base: master
Are you sure you want to change the base?
Conversation
Vendor optimized base64 implementation from https://github.com/aklomp/base64. This is based on commit 9e8ed65048ff0f703fad3deb03bf66ac7f78a4d7 (May 2025). Enable SIMD on macOS (64-bit ARM only). Other platforms probably use a generic version. I'll look into enabling SIMD more generally in a follow-up PR. A `b64encode` micro-benchmark was up to 11 times faster compared to the stdlib `base64` module (on a MacBook Pro).
lib-rt/setup.py
Outdated
| if compiler.compiler_type == "unix": | ||
| cflags += ["-O3"] | ||
| if X86_64: | ||
| cflags.append("-msse4.2") # Enable SIMD (see also mypyc/build.py) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No auto detection? I'll have to patch this out for Debian, the amd64 baseline is sse2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| cflags.append("-msse4.2") # Enable SIMD (see also mypyc/build.py) |
There is autodetection already, -msse4.2 is not needed: https://github.com/mypyc/librt/pull/14/files#diff-25f140cc37c41f9eb31ca08bca258a6bb6f86e404efde9344762e6aaac4d5494R188-R203
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the original mypy PR python/mypy#20244 that added this, I guess it was necessary for some compilers, maybe @JukkaL can clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build fails without this, since SSE4.2 features can't be used without the flag, at least on Ubuntu 24.04. In particular, the C files within arch/sse in the path may need this flag. Auto-detection is supported by the underlying base64 library, but we'd still need to compile the SSE-related files using this flag, and setuptools doesn't make it straightforward to have different C compiler flags for specific files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a fix for per-file compile flags python/mypy#20253
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilevkivskyi @JukkaL The fix for per-file base64 compilation flags is ready for review & merging python/mypy#20253
|
The per-file compilation flag PR was merged and this PR can be updated to reflect it (Ihttps://github.com/python/mypy/pull/20253). |
|
OK, I will probably re-run the sync to also include other recent changes to |
|
For the "pyodide" error
I recommend using the neon64 codec + |
|
I also recommend making wasm64 wheels as well as the existing wasm32 wheels |
|
|
|
Here's a patch to fix the pyodide build (and use the NEON SIMD intrinsics on this route) |
I see now that pyodide doesn't support wasm64 yet: https://pyodide.org/en/stable/usage/api/js-api.html#pyodide.LockfileInfo.arch |
Could you make a PR to mypy first (if you have time)? Normally things should go there first, I (or Jukka will then sync those here). Not sure if your fix is affected by this. |
Sure, though there is no pyodide CI in the mypy repo
My fix doesn't have that problem, no. I tested locally using |
We used to build WASM wheels for mypy, they are temporarily disabled (because mypy now depends on librt, so things get tricky without PyPI support for WASM), but as I said it is better keep things ready :-) |
|
Hm, @mr-c now there are some weird compile errors in WASM build: |
|
Interestingly, the errors only appear in Python 3.12 WASM build, Python 3.13 works fine. |
Ah, I was testing with Python 3.13. I will look into this soon |
|
@ilevkivskyi Fix for Pyodide with Python 3.12 is at python/mypy#20342 |
Fixes the issue reported at mypyc/librt#14 (comment) For Python 3.12, [the pyodide_2024_0 ABI requires emscripten 3.1.58](https://pyodide.org/en/stable/development/abi.html#pyodide-2024-0), which uses an older version of SIMDe that doesn't include all the NEON 64-bit intrinsics we need. So we use the 32-bit NEON intrinsics implementation of base64 for Pyodide on Python 3.12, and use the 64-bit NEON intrinsics implementations of base64 for Pyodide on Python 3.13. [Pyodide for Python 3.13, the pyodide_2025_0 ABI, uses emscripten 4.0.9](https://pyodide.org/en/stable/development/abi.html#pyodide-2025-0-under-development) Emscripten versdion 3.1.63 appears to be the first version with the updated SIMDe versions: emscripten-core/emscripten@6223c43
No description provided.