KEMBAR78
[mypyc] Add primitives for bitwise ops by JukkaL · Pull Request #9529 · python/mypy · GitHub
Skip to content

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Oct 3, 2020

This adds primitives for &, |, ^, <<, >> and ~. These speed up a
bitwise op microbenchmark by about 10x on Linux.

Long integer operations are only slightly faster, except for certain cases
of mixed short/long integers, where we are significantly faster (but only
maybe 1.5x or so).

Also support bool when relevant, since it's a subclass of int and
overrides some operations.

Work on mypyc/mypyc#751.

@JukkaL JukkaL requested a review from msullivan October 3, 2020 13:19
@JukkaL
Copy link
Collaborator Author

JukkaL commented Oct 3, 2020

Hmm I'm going to have to specialize some of the ops for booleans as well, as otherwise the integer ops will be used, resulting in runtime type errors.

Copy link
Collaborator

@TH3CHARLie TH3CHARLie left a comment

Choose a reason for hiding this comment

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

Overall LGTM and that's a great improvement!

@JukkaL JukkaL merged commit 6b0f7d7 into master Oct 6, 2020
@JukkaL JukkaL deleted the bitwise-ops branch October 6, 2020 09:49
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