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

[mypyc] Faster bool and integer conversions #14422

Merged
merged 13 commits into from
Jan 11, 2023
Merged

[mypyc] Faster bool and integer conversions #14422

merged 13 commits into from
Jan 11, 2023

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Jan 10, 2023

Speed up various conversions between bool and integer types. These cases are covered:

  • bool(x) for various types
  • int(x) for bool and integer arguments
  • Implicit coercion from bool to an integer type

Support both regular int values and native int values.

(Various small optimizations, including these, together netted a 6% performance improvement in self check.)

@JukkaL JukkaL merged commit c4a5f56 into master Jan 11, 2023
@JukkaL JukkaL deleted the mypyc-bool branch January 11, 2023 17:23
JukkaL pushed a commit that referenced this pull request Jan 18, 2023
int() and float() calls on native classes can simply call the associated
dunder if the RInstance defines it, no need to load the type and call
it.

bool() calls were already optimized merely a few days ago, but there
wasn't an IRbuild test verifying this so I added one.

---

Follow up to #14422. I saw the PR and
it reminded me that I had this old patch laying around :)
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.

2 participants