Skip to content

[mypyc] Enable native integers outside tests #14606

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

Merged
merged 9 commits into from
Feb 6, 2023
Merged

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Feb 4, 2023

I think that native integers work well enough to enable them outside tests.

Require a more recent mypy_extensions that includes native int types, including i64 and i32.

Add definitions of i64 and i32 to the bundled stubs for mypy_extensions. Fork the stubs, since the definitions only make sense for mypy/mypyc. They require custom type checking logic. Other tools can treat these as aliases to int, which was implemented here: python/typeshed#9675

Also fix serialization of native int TypeInfos. Since we patch builtins.int when we process mypy_extensions, the patched information may not be serialized. We'll also need to perform similar patching during deserialization.

Here is the performance impact to some benchmarks when using i64 instead of int types (these assume some additional tweaks that should be ready soon):

  • richards: 33% faster
  • hexiom: 18% faster
  • deltablue: 2.6% faster

Perhaps more importantly, native integers help with upcoming low-level features, such as packed arrays.

Closes mypyc/mypyc#837. Remaining work can be tracked in separate issues.

JukkaL added a commit to mypyc/mypyc-benchmarks that referenced this pull request Feb 4, 2023
@github-actions

This comment has been minimized.

This requires an ugly hack to also correctly deserialize the native
int references in the _promote attribute of `int`, since we modify it
during semantic analysis when processing `mypy_extensions`, even
though builtins may already have been serialized without this change.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JukkaL JukkaL merged commit dc03478 into master Feb 6, 2023
@JukkaL JukkaL deleted the enable-native-ints branch February 6, 2023 19:28
JukkaL added a commit to mypyc/mypyc-benchmarks that referenced this pull request Apr 30, 2023
JukkaL added a commit to mypyc/mypyc-benchmarks that referenced this pull request Apr 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Native integers
2 participants