Skip to content

Commit

Permalink
Dont use 'all' for only one compare.
Browse files Browse the repository at this point in the history
  • Loading branch information
splitline committed Jul 13, 2021
1 parent 95236d6 commit 61086e0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,10 @@ def parse_Set():
self.bytecode += pickle.ADDITEMS

def parse_Compare():
# a>b>c -> all((a>b, b>c))
self.find_class("builtins", 'all')
# a > b > c -> all((a > b, b > c))
tuple_size = len(node.ops)
if tuple_size > 1:
self.find_class("builtins", 'all')
if tuple_size > 3:
self.bytecode += pickle.MARK # TUPLE mark
left = node.left
Expand All @@ -270,10 +271,10 @@ def parse_Compare():
(left, right)
)
left = right
self.bytecode += self.get_tuple_code(tuple_size)
# /TUPLE

self.bytecode += pickle.TUPLE1 + pickle.REDUCE
if tuple_size > 1:
self.bytecode += self.get_tuple_code(tuple_size)
self.bytecode += pickle.TUPLE1 + pickle.REDUCE

# TODO: BoolOp
# elif node_type in [ast.BinOp, ast.UnaryOp]:
Expand Down

0 comments on commit 61086e0

Please sign in to comment.