summaryrefslogtreecommitdiff
path: root/Lib/dis.py
diff options
context:
space:
mode:
authorDennis Sweeney <36520290+sweeneyde@users.noreply.github.com>2022-06-21 06:19:26 -0400
committerGitHub <noreply@github.com>2022-06-21 11:19:26 +0100
commit5fcfdd87c9b5066a581d3ccb4b2fede938f343ec (patch)
tree8d333af15ee960d109d32163e005beefb2a16900 /Lib/dis.py
parentc735d545343c3ab002c62596b2fb2cfa4488b0af (diff)
downloadcpython-git-5fcfdd87c9b5066a581d3ccb4b2fede938f343ec.tar.gz
GH-91432: Specialize FOR_ITER (GH-91713)
* Adds FOR_ITER_LIST and FOR_ITER_RANGE specializations. * Adds _PyLong_AssignValue() internal function to avoid temporary boxing of ints.
Diffstat (limited to 'Lib/dis.py')
-rw-r--r--Lib/dis.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index 355f468301..bd87de97fc 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -37,6 +37,7 @@ LOAD_CONST = opmap['LOAD_CONST']
LOAD_GLOBAL = opmap['LOAD_GLOBAL']
BINARY_OP = opmap['BINARY_OP']
JUMP_BACKWARD = opmap['JUMP_BACKWARD']
+FOR_ITER = opmap['FOR_ITER']
LOAD_ATTR = opmap['LOAD_ATTR']
CACHE = opmap["CACHE"]
@@ -476,6 +477,8 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
+ if deop == FOR_ITER:
+ argval += 2
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
@@ -629,11 +632,14 @@ def findlabels(code):
labels = []
for offset, op, arg in _unpack_opargs(code):
if arg is not None:
- if op in hasjrel:
- if _is_backward_jump(op):
+ deop = _deoptop(op)
+ if deop in hasjrel:
+ if _is_backward_jump(deop):
arg = -arg
label = offset + 2 + arg*2
- elif op in hasjabs:
+ if deop == FOR_ITER:
+ label += 2
+ elif deop in hasjabs:
label = arg*2
else:
continue