Ken Jin <[email protected]> added the comment:
> Will this change be reflected in co_code?
No. As per PEP 659:
"Once any instruction in a code object has executed a few times, that code
object will be "quickened" by allocating a new array for the bytecode that can
be modified at runtime, and is not constrained as the code.co_code object is."
Example:
x = lambda a: len(a)
print(x.__code__.co_code)
#quickened
for _ in range(10):
x('')
print(x.__code__.co_code)
There should be no change.
> If not, how would it deal with co_code being modified?
Disclaimer: I am not a contributor to such libraries, so my knowledge in this
area is limited.
co_code is readonly and the bytes object it points is also immutable. So I'd
imagine that they'd have to create a brand new code object, in which case it
shouldn't matter. But if there is some way to modify co_code in-place using
ctypes: I don't know. Sorry! The best way to find out is to test those
libraries with 3.11 and see if such functionality breaks, then file a bug
report here please. Thank you.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45362>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com