Abstract Object Layer

The functions in Tables B.4 through B.8 are used to manipulate objects from C, in much the same manner as from the interpreter. All the functions in this section that return an int return -1 if an error occurs. Likewise, functions that return a PyObject * return NULL on failure. Note that an “error” in this context is not the same as the false result of a test. For instance, the PyNumber_Check(PyObject *obj ) function returns 0 if obj is not a number, but this isn’t the same as an error. Finally, unless otherwise noted, all functions in this section that return a PyObject * return ownership with the object. It’s up to the caller to decrement the reference count of the returned object if necessary.

Table B.4. Objects
Type ...

Get Python Essential Reference, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.