summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2021-06-15 22:35:25 (GMT)
committerGitHub <noreply@github.com>2021-06-15 22:35:25 (GMT)
commitac38a9f2dfbba95f5d4338eb11a0221d38ef9328 (patch)
treecbe976854afe2fc55df27e5134abc9cdc727c601 /Lib/importlib
parent1d10bf0bb9409a406c56b0de8870df998637fd0f (diff)
downloadcpython-ac38a9f2dfbba95f5d4338eb11a0221d38ef9328.zip
cpython-ac38a9f2dfbba95f5d4338eb11a0221d38ef9328.tar.gz
cpython-ac38a9f2dfbba95f5d4338eb11a0221d38ef9328.tar.bz2
bpo-43693: Eliminate unused "fast locals". (gh-26587)
Currently, if an arg value escapes (into the closure for an inner function) we end up allocating two indices in the fast locals even though only one gets used. Additionally, using the lower index would be better in some cases, such as with no-arg `super()`. To address this, we update the compiler to fix the offsets so each variable only gets one "fast local". As a consequence, now some cell offsets are interspersed with the locals (only when an arg escapes to an inner function). https://bugs.python.org/issue43693
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_bootstrap_external.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index 3cbbb80..7bf19fe 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -358,6 +358,7 @@ _code_type = type(_write_atomic.__code__)
# Python 3.11a1 3453 (add co_fastlocalnames and co_fastlocalkinds)
# Python 3.11a1 3454 (compute cell offsets relative to locals bpo-43693)
# Python 3.11a1 3455 (add MAKE_CELL bpo-43693)
+# Python 3.11a1 3456 (interleave cell args bpo-43693)
#
# MAGIC must change whenever the bytecode emitted by the compiler may no
@@ -367,7 +368,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 = (3455).to_bytes(2, 'little') + b'\r\n'
+MAGIC_NUMBER = (3456).to_bytes(2, 'little') + b'\r\n'
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c
_PYCACHE = '__pycache__'