-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Closed
Copy link
Labels
3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage
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.
Linked PRs
Eclips4
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage