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] Fast tuple equality checks #9343

Merged
merged 12 commits into from
Aug 27, 2020
Prev Previous commit
Next Next commit
change special case position to support nested tuples
  • Loading branch information
TH3CHARLie committed Aug 23, 2020
commit b13208aba627e16a74d10b806a5e81df8fa31b46
4 changes: 0 additions & 4 deletions mypyc/irbuild/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,6 @@ def unary_op(self, lreg: Value, expr_op: str, line: int) -> Value:
return self.builder.unary_op(lreg, expr_op, line)

def binary_op(self, lreg: Value, rreg: Value, expr_op: str, line: int) -> Value:
# special case tuple comparison here so that nested tuples can be supported
if (isinstance(lreg.type, RTuple) and isinstance(rreg.type, RTuple)
and expr_op in ('==', '!=')):
return self.compare_tuples(lreg, rreg, expr_op, line)
return self.builder.binary_op(lreg, rreg, expr_op, line)

def coerce(self, src: Value, target_type: RType, line: int, force: bool = False) -> Value:
Expand Down
4 changes: 4 additions & 0 deletions mypyc/irbuild/ll_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,10 @@ def binary_op(self,
rreg: Value,
expr_op: str,
line: int) -> Value:
# special case tuple comparison here so that nested tuples can be supported
if (isinstance(lreg.type, RTuple) and isinstance(rreg.type, RTuple)
and expr_op in ('==', '!=')):
return self.compare_tuples(lreg, rreg, expr_op, line)
# Special case == and != when we can resolve the method call statically.
value = None
if expr_op in ('==', '!='):
Expand Down