Skip to content

Commit dd36d2f

Browse files
committed
Tidy up test help function
1 parent 74b40c3 commit dd36d2f

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,17 @@ def f(start, end, way):
152152
f(0, TIER2_THRESHOLD, 1)
153153
f(1, TIER2_THRESHOLD + 1, 1.0)
154154

155+
155156
def get_bool_guard_ops():
156-
d = id(True) ^ id(False)
157-
bit = 0
158-
for i in range(4, 8):
159-
if d & (1 << i):
160-
bit = i
161-
break
162-
if bit == 0:
163-
return "_GUARD_IS_FALSE_POP", "_GUARD_IS_TRUE_POP"
164-
if id(True) & (1 << bit):
165-
return f"_GUARD_BIT_IS_UNSET_POP_{bit}", f"_GUARD_BIT_IS_SET_POP_{bit}"
166-
else:
167-
return f"_GUARD_BIT_IS_SET_POP_{bit}", f"_GUARD_BIT_IS_UNSET_POP_{bit}"
157+
delta = id(True) ^ id(False)
158+
for bit in range(4, 8):
159+
if delta & (1 << bit):
160+
if id(True) & (1 << bit):
161+
return f"_GUARD_BIT_IS_UNSET_POP_{bit}", f"_GUARD_BIT_IS_SET_POP_{bit}"
162+
else:
163+
return f"_GUARD_BIT_IS_SET_POP_{bit}", f"_GUARD_BIT_IS_UNSET_POP_{bit}"
164+
return "_GUARD_IS_FALSE_POP", "_GUARD_IS_TRUE_POP"
165+
168166

169167
@requires_specialization
170168
@unittest.skipIf(Py_GIL_DISABLED, "optimizer not yet supported in free-threaded builds")

0 commit comments

Comments
 (0)