[issue36839] Support the buffer protocol in code objects

Inada Naoki report at bugs.python.org
Tue May 28 23:15:14 EDT 2019


Inada Naoki <songofacandy at gmail.com> added the comment:

> Could someone create a buffer object which still allows the underlying memory to be written?  Sure.  But I can use ctypes to modify byte code today as well with something like "ctypes.cast(id(f.__code__.co_code) + 32, ctypes.POINTER(ctypes.c_char)) [0] = 101" 

You are comparing apple and orange.
Breanking memory inside immutable object by ctypes is far different from mutating mutable memory.

It introduce more weakness and complexity into code object.

At least, you need to demonstrate the benefit.

When importing module, there are many objects are created.  Why avoiding decref only for co_code make much difference?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36839>
_______________________________________


More information about the Python-bugs-list mailing list