summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2023-04-24 22:22:14 (GMT)
committerGitHub <noreply@github.com>2023-04-24 22:22:14 (GMT)
commit0dc8b50d33208e9ca4fc3d959c6798529731f020 (patch)
tree822102a5177183fc6ad7075bd74a02a5633edc52 /Lib/importlib
parent22bed58e531ce780d91f3364c5ace98fad28c2e8 (diff)
downloadcpython-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/importlib')
-rw-r--r--Lib/importlib/_bootstrap_external.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index c0c757d..74a78bc 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -439,7 +439,8 @@ _code_type = type(_write_atomic.__code__)
# Python 3.12a7 3523 (Convert COMPARE_AND_BRANCH back to COMPARE_OP)
# Python 3.12a7 3524 (Shrink the BINARY_SUBSCR caches)
# Python 3.12b1 3525 (Shrink the CALL caches)
-# Python 3.12a7 3526 (Add instrumentation support)
+# Python 3.12b1 3526 (Add instrumentation support)
+# Python 3.12b1 3527 (Optimize super() calls)
# Python 3.13 will start with 3550
@@ -456,7 +457,7 @@ _code_type = type(_write_atomic.__code__)
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.
-MAGIC_NUMBER = (3526).to_bytes(2, 'little') + b'\r\n'
+MAGIC_NUMBER = (3527).to_bytes(2, 'little') + b'\r\n'
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c