Skip to content

Commit 6283691

Browse files
committed
#11983: update comment to describe which fields are used and why.
Original patch by Caelyn McAulay; modified after discussion w/ her at the PyCon 2014 sprints.
1 parent 7f54b2b commit 6283691

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Include/code.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ typedef struct {
2121
PyObject *co_varnames; /* tuple of strings (local variable names) */
2222
PyObject *co_freevars; /* tuple of strings (free variable names) */
2323
PyObject *co_cellvars; /* tuple of strings (cell variable names) */
24-
/* The rest doesn't count for hash or comparisons */
24+
/* The rest aren't used in either hash or comparisons, except for
25+
co_name (used in both) and co_firstlineno (used only in
26+
comparisons). This is done to preserve the name and line number
27+
for tracebacks and debuggers; otherwise, constant de-duplication
28+
would collapse identical functions/lambdas defined on different lines.
29+
*/
2530
unsigned char *co_cell2arg; /* Maps cell vars which are arguments. */
2631
PyObject *co_filename; /* unicode (where it was loaded from) */
2732
PyObject *co_name; /* unicode (name, for reference) */

0 commit comments

Comments
 (0)