Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions 26 Lib/test/test_peepholer.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,24 +293,32 @@ def f(cond, true_value, false_value):

def test_elim_jump_to_uncond_jump(self):
# POP_JUMP_IF_FALSE to JUMP_FORWARD --> POP_JUMP_IF_FALSE to non-jump
# JUMP_FORWARD to JUMP_FORWARD --> JUMP_FORWARD to non-jump
def f():
if a:
# Intentionally use two-line expression to test issue37213.
if (c
or d):
foo()
if b:
# Intentionally use two-line expression to test issue37213.
if (c
or d):
foo()
else:
bar()
else:
baz()
self.check_jump_targets(f)

def test_elim_jump_to_uncond_jump2(self):
# POP_JUMP_IF_FALSE to JUMP_ABSOLUTE --> POP_JUMP_IF_FALSE to non-jump
# JUMP_FORWARD to JUMP_ABSOLUTE --> JUMP_FORWARD to non-jump
def f():
while a:
# Intentionally use two-line expression to test issue37213.
if (c
or d):
a = foo()
if b:
# Intentionally use two-line expression to test issue37213.
if (c
or d):
a = foo()
else:
a = bar()
self.check_jump_targets(f)

def test_elim_jump_to_uncond_jump3(self):
Expand Down Expand Up @@ -370,7 +378,7 @@ def f(cond1, cond2):
# There should be one jump for the while loop.
returns = [instr for instr in dis.get_instructions(f)
if instr.opname == 'JUMP_ABSOLUTE']
self.assertEqual(len(returns), 1)
self.assertEqual(len(returns), 0)
returns = [instr for instr in dis.get_instructions(f)
if instr.opname == 'RETURN_VALUE']
self.assertLessEqual(len(returns), 2)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The peephole optimizer now does multiple runs until the resulting bytecode
cannot be optimized further. Patch by Pablo Galindo.
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.