Cell Objects¶
“Cell” objects are used to implement variables referenced by multiple scopes.For each such variable, a cell object is created to store the value; the localvariables of each stack frame that references the value contains a reference tothe cells from outer scopes which also use that variable. When the value isaccessed, the value contained in the cell is used instead of the cell objectitself. This de-referencing of the cell object requires support from thegenerated byte-code; these are not automatically de-referenced when accessed.Cell objects are not likely to be useful elsewhere.
PyCellObject¶The C structure used for cell objects.
- PyTypeObject
PyCell_Type¶ The type object corresponding to cell objects.
- int
PyCell_Check(ob)¶ Return true ifob is a cell object;ob must not be
NULL. Thisfunction always succeeds.
- PyObject*
PyCell_New(PyObject *ob)¶ - Return value: New reference.
Create and return a new cell object containing the valueob. The parameter maybe
NULL.
- PyObject*
PyCell_Get(PyObject *cell)¶ - Return value: New reference.
Return the contents of the cellcell.
- PyObject*
PyCell_GET(PyObject *cell)¶ - Return value: Borrowed reference.
Return the contents of the cellcell, but without checking thatcell isnon-
NULLand a cell object.