diff options
author | Mark Shannon <mark@hotpy.org> | 2021-11-23 09:53:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 09:53:24 (GMT) |
commit | 135cabd328504e1648d17242b42b675cdbd0193b (patch) | |
tree | 4efa5418b1816ba02c206678ecfa4e2d8e8d8f14 /Lib/test/test_code.py | |
parent | d82f2caf942fa8b94e797a2f116ee54ec303c2df (diff) | |
download | cpython-135cabd328504e1648d17242b42b675cdbd0193b.zip cpython-135cabd328504e1648d17242b42b675cdbd0193b.tar.gz cpython-135cabd328504e1648d17242b42b675cdbd0193b.tar.bz2 |
bpo-44525: Copy free variables in bytecode to allow calls to inner functions to be specialized (GH-29595)
* Make internal APIs that take PyFrameConstructor take a PyFunctionObject instead.
* Add reference to function to frame, borrow references to builtins and globals.
* Add COPY_FREE_VARS instruction to allow specialization of calls to inner functions.
Diffstat (limited to 'Lib/test/test_code.py')
-rw-r--r-- | Lib/test/test_code.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py index 0d46258..b42213b 100644 --- a/Lib/test/test_code.py +++ b/Lib/test/test_code.py @@ -141,6 +141,8 @@ from test.support import (cpython_only, check_impl_detail, requires_debug_ranges, gc_collect) from test.support.script_helper import assert_python_ok +from opcode import opmap +COPY_FREE_VARS = opmap['COPY_FREE_VARS'] def consts(t): @@ -185,7 +187,7 @@ class CodeTest(unittest.TestCase): def new_code(c): '''A new code object with a __class__ cell added to freevars''' - return c.replace(co_freevars=c.co_freevars + ('__class__',)) + return c.replace(co_freevars=c.co_freevars + ('__class__',), co_code=bytes([COPY_FREE_VARS, 1])+c.co_code) def add_foreign_method(cls, name, f): code = new_code(f.__code__) |