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/dis.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/dis.py')
| -rw-r--r-- | Lib/dis.py | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -41,6 +41,7 @@ JUMP_BACKWARD = opmap['JUMP_BACKWARD'] FOR_ITER = opmap['FOR_ITER'] SEND = opmap['SEND'] LOAD_ATTR = opmap['LOAD_ATTR'] +LOAD_SUPER_ATTR = opmap['LOAD_SUPER_ATTR'] CACHE = opmap["CACHE"] @@ -475,6 +476,10 @@ def _get_instructions_bytes(code, varname_from_oparg=None, argval, argrepr = _get_name_info(arg//2, get_name) if (arg & 1) and argrepr: argrepr = "NULL|self + " + argrepr + elif deop == LOAD_SUPER_ATTR: + argval, argrepr = _get_name_info(arg//4, get_name) + if (arg & 1) and argrepr: + argrepr = "NULL|self + " + argrepr else: argval, argrepr = _get_name_info(arg, get_name) elif deop in hasjabs: |
