Skip to content

Commit a995a2d

Browse files
committed
Document what the members of PyListObject are used for, and the crucial
invariants they must satisfy.
1 parent b38e2b6 commit a995a2d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Include/listobject.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ extern "C" {
2121

2222
typedef struct {
2323
PyObject_VAR_HEAD
24+
/* Vector of pointers to list elements. list[0] is ob_item{0], etc. */
2425
PyObject **ob_item;
26+
27+
/* ob_item contains space for 'allocated' elements. The number
28+
* currently in use is ob_size.
29+
* Invariants:
30+
* 0 <= ob_size <= allocated
31+
* len(list) == ob_size
32+
* ob_item == NULL implies ob_size == allocated == 0
33+
*/
2534
int allocated;
2635
} PyListObject;
2736

0 commit comments

Comments
 (0)