Objek Sel, Cell

Objek-objek "Cell" digunakan untuk mengimplementasi variabel-variabel yang direferensikan oleh beberapa scopes. Untuk variable seperti itu, sebuah objek cell dibuat untuk menyimpan nilai; variabel lokal dari setiap kerangka stack yang mereferensikan nilai yang memiliki referensi ke cells dari scopes luar yang juga menggunakan variabel tersebut. Ketika nilai diakses, nilai yang dimiliki cell digunakan alih-alih objek cell itu sendiri. De-referencing dari objek cell ini membutuhkan dukungan dari kode byte yang dihasilkan; bagian ini tidak secara otomatis mengalami de-referenced ketika diakses. Objek-objek Cell sepertinya tidak akan berguna di tempat lain.

PyCellObject

Struktur C digunakan untuk objek sel.

PyTypeObject PyCell_Type

Tipe objek yang sesuai dengan objek sel.

int PyCell_Check(ob)

Return true if ob is a cell object; ob must not be NULL.

PyObject* PyCell_New(PyObject *ob)
Return value: New reference.

Create and return a new cell object containing the value ob. The parameter may be NULL.

PyObject* PyCell_Get(PyObject *cell)
Return value: New reference.

Kembalikan isi sel cell.

PyObject* PyCell_GET(PyObject *cell)
Return value: Borrowed reference.

Return the contents of the cell cell, but without checking that cell is non-NULL and a cell object.

int PyCell_Set(PyObject *cell, PyObject *value)

Set the contents of the cell object cell to value. This releases the reference to any current content of the cell. value may be NULL. cell must be non-NULL; if it is not a cell object, -1 will be returned. On success, 0 will be returned.

void PyCell_SET(PyObject *cell, PyObject *value)

Sets the value of the cell object cell to value. No reference counts are adjusted, and no checks are made for safety; cell must be non-NULL and must be a cell object.