[Python-Dev] attributes of Python code objects
brett at python.org
Sun Feb 26 15:44:16 EST 2017
On Sun, 26 Feb 2017 at 02:20 Xavier de Gaye <xdegaye at gmail.com> wrote:
> In PR 218 , INADA Naoki wrote:
> > I think attributes of Python's code object is implementation detail,
> > though PyPy follows.
> > But it's not big problem until there are some Python implementation
> > having different code implementation.
> Python's code object attributes are described in the Data Model 
> section of
> the documentation. 1) Is this description normative (to be followed by
> all the
> implementations of the Python language)? 2) Is the description of
> in  normative ?
That's a good question. "Code objects represent byte-compiled executable
Python code, or bytecode" which would suggest that if an implementation
didn't have a compiled code then code objects wouldn't make sense. Then
again the object contains details about the function that can be useful and
are relied upon by parts of the stdlib (e.g. inspect.signature() can't
function without the code object).
Due to that last point I would say the attributes on code objects are not
an implementation detail, but it's acceptable for things like co_code to be
set to None when it doesn't make sense.
>  https://github.com/python/cpython/pull/218
>  https://docs.python.org/3/reference/datamodel.html
>  https://github.com/python/cpython/blob/master/Objects/lnotab_notes.txt
> Python-Dev mailing list
> Python-Dev at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev