KEMBAR78
[mypyc] Inline tagged integer arithmetic and bitwise operations by JukkaL · Pull Request #17265 · python/mypy · GitHub
Skip to content

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented May 19, 2024

Inline the fast path of various tagged integer operations by using C inline functions.
Most of these operations are very quick, so getting rid of the overhead of a C call
improves performance significantly. This also enables the C compiler to optimize
things more, if there are constant operands, for example.

This speeds up an older version of the richards benchmark, which didn't use native
integers, by 10% (on CPython 3.12). Even bigger improvements are possible in
some microbenchmarks.

We didn't do this in the past because of worries about compilation time. However,
I couldn't measure an impact to self-compilation speed, and the binary size is
only increased by about 0.1%.

Work on mypyc/mypyc#757.

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@JukkaL JukkaL merged commit 09c48a4 into master Jun 6, 2024
@JukkaL JukkaL deleted the mypyc-int-inline branch June 6, 2024 09:35
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