def PyObject_InitVar(space, py_obj, type, size): """This does everything PyObject_Init() does, and also initializes the length information for a variable-size object.""" if not py_obj: PyErr_NoMemory(space) py_obj.c_ob_size = size return PyObject_Init(space, rffi.cast(PyObject, py_obj), type)
def PyObject_Init(space, obj, type): """Initialize a newly-allocated object op with its type and initial reference. Returns the initialized object. If type indicates that the object participates in the cyclic garbage detector, it is added to the detector's set of observed objects. Other fields of the object are not affected.""" if not obj: PyErr_NoMemory(space) obj.c_ob_type = type _Py_NewReference(space, obj) return obj