diff options
author | Carl Meyer <carl@oddbird.net> | 2023-04-24 22:22:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-24 22:22:14 (GMT) |
commit | 0dc8b50d33208e9ca4fc3d959c6798529731f020 (patch) | |
tree | 822102a5177183fc6ad7075bd74a02a5633edc52 /Lib/opcode.py | |
parent | 22bed58e531ce780d91f3364c5ace98fad28c2e8 (diff) | |
download | cpython-0dc8b50d33208e9ca4fc3d959c6798529731f020.zip cpython-0dc8b50d33208e9ca4fc3d959c6798529731f020.tar.gz cpython-0dc8b50d33208e9ca4fc3d959c6798529731f020.tar.bz2 |
gh-87729: add LOAD_SUPER_ATTR instruction for faster super() (#103497)
This speeds up `super()` (by around 85%, for a simple one-level
`super().meth()` microbenchmark) by avoiding allocation of a new
single-use `super()` object on each use.
Diffstat (limited to 'Lib/opcode.py')
-rw-r--r-- | Lib/opcode.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/opcode.py b/Lib/opcode.py index dd739e5..e7b346e 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -196,7 +196,7 @@ hasfree.append(138) def_op('DELETE_DEREF', 139) hasfree.append(139) jrel_op('JUMP_BACKWARD', 140) # Number of words to skip (backwards) - +name_op('LOAD_SUPER_ATTR', 141) def_op('CALL_FUNCTION_EX', 142) # Flags def_op('EXTENDED_ARG', 144) @@ -264,6 +264,9 @@ pseudo_op('JUMP', 260, ['JUMP_FORWARD', 'JUMP_BACKWARD']) pseudo_op('JUMP_NO_INTERRUPT', 261, ['JUMP_FORWARD', 'JUMP_BACKWARD_NO_INTERRUPT']) pseudo_op('LOAD_METHOD', 262, ['LOAD_ATTR']) +pseudo_op('LOAD_SUPER_METHOD', 263, ['LOAD_SUPER_ATTR']) +pseudo_op('LOAD_ZERO_SUPER_METHOD', 264, ['LOAD_SUPER_ATTR']) +pseudo_op('LOAD_ZERO_SUPER_ATTR', 265, ['LOAD_SUPER_ATTR']) MAX_PSEUDO_OPCODE = MIN_PSEUDO_OPCODE + len(_pseudo_ops) - 1 |