Closed
Description
Currently, the zeroth constant in a code object's co_consts
tuple is the docstring, iff it is a string.
This means that any code object without a docstring must not have a string as its first constant. To guarantee this we generally insert None
as the first constant.
This prevents a few improvements we would like to make, such as moving None
from LOAD_CONST
to LOAD_COMMON_CONST
,
and complicates handling of code objects in the compiler.
I propose adding a flag to co_flags
, CO_HAS_DOCSTRING
. If this flag is set then the docstring is the zeroth string, otherwise there is no docstring.