8000 [mypyc] Generate faster code for bool comparisons and arithmetic by JukkaL · Pull Request #14489 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

[mypyc] Generate faster code for bool comparisons and arithmetic #14489

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 13 commits into from
Feb 5, 2023
Prev Previous commit
Next Next commit
Add test case
  • Loading branch information
JukkaL committed Jan 21, 2023
commit 050c561584ab7b14265fa9bab23df09ab68ec165
11 changes: 11 additions & 0 deletions mypyc/test-data/irbuild-bool.test
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ L0:
return r1

[case testBoolBitwise]
from mypy_extensions import i64
def bitand(x: bool, y: bool) -> bool:
b = x & y
return b
Expand All @@ -355,6 +356,8 @@ def bitxor(x: bool, y: bool) -> bool:
return b
def invert(x: bool) -> int:
return ~x
def mixed_bitand(x: i64, y: bool) -> i64:
return x & y
[out]
def bitand(x, y):
x, y, r0, b :: bool
Expand Down Expand Up @@ -382,6 +385,14 @@ L0:
r1 = extend r0: builtins.bool to builtins.int
r2 = CPyTagged_Invert(r1)
return r2
def mixed_bitand(x, y):
x :: int64
y :: bool
r0, r1 :: int64
L0:
r0 = extend y: builtins.bool to int64
4A61 r1 = x & r0
return r1

[case testBoolArithmetic]
def add(x: bool, y: bool) -> int:
Expand Down
0