#
10. Defining New Object Types

PyObject* `_PyObject_New`(PyTypeObject *type)
  Return value: New reference.

PyVarObject* `_PyObject_NewVar`(PyTypeObject *type, int size)

void `_PyObject_Del`(PyObject *op)

PyObject* `PyObject_Init`(PyObject *op, PyTypeObject *type)
  Return value: Borrowed reference.

PyVarObject* `PyObject_InitVar`(PyVarObject *op, PyTypeObject *type, int size)

TYPE* `PyObject_New`(TYPE, PyTypeObject *type)

TYPE* `PyObject_NewVar`(TYPE, PyTypeObject *type, int size)

void `PyObject_Del`(PyObject *op)

TYPE* `PyObject_NEW`(TYPE, PyTypeObject *type)

TYPE* `PyObject_NEW_VAR`(TYPE, PyTypeObject *type, int size)

void `PyObject_DEL`(PyObject *op)

PyObject* `Py_InitModule`(char *name, PyMethodDef *methods)
  Return value: Borrowed reference.
  Create a new module object based on a name and table of functions, returning the new module object.

PyObject* `Py_InitModule3`(char *name, PyMethodDef *methods, char *doc)
  Return value: Borrowed reference.
  Create a new module object based on a name and table of functions, returning the new module object. If doc is non-`NULL`, it will be used to define the docstring for the module.

PyObject* `Py_InitModule4`(char *name, PyMethodDef *methods, char *doc, PyObject *self, int apiver)
  Return value: Borrowed reference.
  Create a new module object based on a name and table of functions, returning the new module object. If doc is non-`NULL`, it will be used to define the docstring for the module. If self is non-`NULL`, it will passed to the functions of the module as their (otherwise `NULL`) first parameter. (This was added as an experimental feature, and there are no known uses in the current version of Python.) For apiver, the only value which should be passed is defined by the constant `PYTHON_API_VERSION`.

  Note: Most uses of this function should probably be using the `Py_InitModule3()` instead; only use this if you are sure you need it.

PyArg_ParseTupleAndKeywords, PyArg_ParseTuple, PyArg_Parse

Py_BuildValue

DL_IMPORT

_Py_NoneStruct

Subsections

- 10.1 Common Object Structures
- 10.2 Mapping Object Structures
- 10.3 Number Object Structures
- 10.4 Sequence Object Structures
- 10.5 Buffer Object Structures
- 10.6 Supporting Cyclic Garbarge Collection
  - 10.6.1 Example Cycle Collector Support