- PyObject_BorrowedRef
alias PyObject_BorrowedRef = Borrowed!PyObject
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
- PyObject_Bytes
alias PyObject_Bytes = PyObject_Str
- PyType_FastSubclass
alias PyType_FastSubclass = PyType_HasFeature
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
- allocfunc
alias allocfunc = PyObject* function(PyTypeObject*, Py_ssize_t)
- binaryfunc
alias binaryfunc = PyObject* function(PyObject*, PyObject*)
- charbufferproc
alias charbufferproc = Py_ssize_t function(PyObject*, Py_ssize_t, char**)
ssize_t-based buffer interface
Availability: 2.*
- cmpfunc
alias cmpfunc = int function(PyObject*, PyObject*)
- coercion
alias coercion = int function(PyObject**, PyObject**)
- descrgetfunc
alias descrgetfunc = PyObject* function(PyObject*, PyObject*, PyObject*)
- descrsetfunc
alias descrsetfunc = int function(PyObject*, PyObject*, PyObject*)
- destructor
alias destructor = void function(PyObject*)
- freefunc
alias freefunc = void function(void*)
- getattrfunc
alias getattrfunc = PyObject* function(PyObject*, char*)
- getattrofunc
alias getattrofunc = PyObject* function(PyObject*, PyObject*)
- getbufferproc
alias getbufferproc = int function(PyObject*, Py_buffer*, int)
- getcharbufferproc
alias getcharbufferproc = charbufferproc
int-based buffer interface
Availability: 2.4
- getiterfunc
alias getiterfunc = PyObject* function(PyObject*)
- getreadbufferproc
alias getreadbufferproc = readbufferproc
- getsegcountproc
alias getsegcountproc = segcountproc
- getwritebufferproc
alias getwritebufferproc = writebufferproc
int-based buffer interface
Availability: 2.4
- hashfunc
alias hashfunc = Py_hash_t function(PyObject*)
- initproc
alias initproc = int function(PyObject*, PyObject*, PyObject*)
- inquiry
alias inquiry = lenfunc
- intargfunc
alias intargfunc = ssizeargfunc
- intintargfunc
alias intintargfunc = ssizessizeargfunc
- intintobjargproc
alias intintobjargproc = ssizessizeobjargproc
- intobjargproc
alias intobjargproc = ssizeobjargproc
- iternextfunc
alias iternextfunc = PyObject* function(PyObject*)
- lenfunc
alias lenfunc = Py_ssize_t function(PyObject*)
- newfunc
alias newfunc = PyObject* function(PyTypeObject*, PyObject*, PyObject*)
- objobjargproc
alias objobjargproc = int function(PyObject*, PyObject*, PyObject*)
- objobjproc
alias objobjproc = int function(PyObject*, PyObject*)
- printfunc
alias printfunc = int function(PyObject*, FILE*, int)
- readbufferproc
alias readbufferproc = Py_ssize_t function(PyObject*, Py_ssize_t, void**)
ssize_t-based buffer interface
Availability: 2.*
- releasebufferproc
alias releasebufferproc = void function(PyObject*, Py_buffer*)
- reprfunc
alias reprfunc = PyObject* function(PyObject*)
- richcmpfunc
alias richcmpfunc = PyObject* function(PyObject*, PyObject*, int)
- segcountproc
alias segcountproc = Py_ssize_t function(PyObject*, Py_ssize_t*)
ssize_t-based buffer interface
Availability: 2.*
- setattrfunc
alias setattrfunc = int function(PyObject*, char*, PyObject*)
- setattrofunc
alias setattrofunc = int function(PyObject*, PyObject*, PyObject*)
- ssizeargfunc
alias ssizeargfunc = PyObject* function(PyObject*, Py_ssize_t)
- ssizeobjargproc
alias ssizeobjargproc = int function(PyObject*, Py_ssize_t, PyObject*)
- ssizessizeargfunc
alias ssizessizeargfunc = PyObject* function(PyObject*, Py_ssize_t, Py_ssize_t)
- ssizessizeobjargproc
alias ssizessizeobjargproc = int function(PyObject*, Py_ssize_t, Py_ssize_t, PyObject*)
- ternaryfunc
alias ternaryfunc = PyObject* function(PyObject*, PyObject*, PyObject*)
- traverseproc
alias traverseproc = int function(PyObject*, visitproc, void*)
- unaryfunc
alias unaryfunc = PyObject* function(PyObject*)
- vectorcallfunc
alias vectorcallfunc = PyObject* function(PyObject* callable, const(PyObject*)* args, size_t nargsf, PyObject* kwnames)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
- visitproc
alias visitproc = int function(PyObject*, void*)
- writebufferproc
alias writebufferproc = Py_ssize_t function(PyObject*, Py_ssize_t, void**)
ssize_t-based buffer interface
Availability: 2.*
- PyCallable_Check
int PyCallable_Check(PyObject* )
- PyNumber_Coerce
int PyNumber_Coerce(PyObject** , PyObject** )
- PyNumber_CoerceEx
int PyNumber_CoerceEx(PyObject** , PyObject** )
- PyObject_ASCII
PyObject* PyObject_ASCII(PyObject* )
- PyObject_Bytes
PyObject* PyObject_Bytes(PyObject* )
- PyObject_ClearWeakRefs
void PyObject_ClearWeakRefs(PyObject* )
- PyObject_Compare
int PyObject_Compare(PyObject* , PyObject* )
- PyObject_Dir
PyObject* PyObject_Dir(PyObject* )
PyObject_Dir(obj) acts like Python __builtin__.dir(obj), returning a
list of strings. PyObject_Dir(NULL) is like __builtin__.dir(),
returning the names of the current locals. In this case, if there are
no current locals, NULL is returned, and PyErr_Occurred() is false.
- PyObject_GenericGetAttr
PyObject* PyObject_GenericGetAttr(PyObject* , PyObject* )
- PyObject_GenericSetAttr
int PyObject_GenericSetAttr(PyObject* , PyObject* , PyObject* )
- PyObject_GetAttr
PyObject* PyObject_GetAttr(PyObject* , PyObject* )
- PyObject_GetAttrString
PyObject* PyObject_GetAttrString(PyObject* , const(char)* )
- PyObject_HasAttr
int PyObject_HasAttr(PyObject* , PyObject* )
- PyObject_HasAttrString
int PyObject_HasAttrString(PyObject* , const(char)* )
- PyObject_Hash
Py_hash_t PyObject_Hash(PyObject* )
- PyObject_HashNotImplemented
Py_hash_t PyObject_HashNotImplemented(PyObject* )
- PyObject_IsTrue
int PyObject_IsTrue(PyObject* )
- PyObject_Not
int PyObject_Not(PyObject* )
- PyObject_Print
int PyObject_Print(PyObject* , FILE* , int )
- PyObject_REPR
auto PyObject_REPR(PyObject* obj)
- PyObject_Repr
PyObject* PyObject_Repr(PyObject* )
- PyObject_RichCompare
PyObject* PyObject_RichCompare(PyObject* , PyObject* , int )
- PyObject_RichCompareBool
int PyObject_RichCompareBool(PyObject* , PyObject* , int )
- PyObject_SelfIter
PyObject* PyObject_SelfIter(PyObject* )
- PyObject_SetAttr
int PyObject_SetAttr(PyObject* , PyObject* , PyObject* )
- PyObject_SetAttrString
int PyObject_SetAttrString(PyObject* , const(char)* , PyObject* )
- PyObject_Str
PyObject* PyObject_Str(PyObject* )
- PyObject_TypeCheck
int PyObject_TypeCheck(PyObject* ob, PyTypeObject* tp)
- PyObject_Unicode
PyObject* PyObject_Unicode(PyObject* )
- PyType_Check
int PyType_Check(PyObject* op)
- PyType_CheckExact
int PyType_CheckExact(PyObject* op)
- PyType_ClearCache
uint PyType_ClearCache()
- PyType_FromSpec
PyObject* PyType_FromSpec(PyType_Spec* )
- PyType_GenericAlloc
PyObject* PyType_GenericAlloc(PyTypeObject* , Py_ssize_t )
- PyType_GenericNew
PyObject* PyType_GenericNew(PyTypeObject* , PyObject* , PyObject* )
- PyType_GetFlags
C_long PyType_GetFlags(PyTypeObject* )
- PyType_HasFeature
int PyType_HasFeature(PyTypeObject* t, int f)
- PyType_IsSubtype
int PyType_IsSubtype(PyTypeObject* , PyTypeObject* )
- PyType_Modified
void PyType_Modified(PyTypeObject* )
- PyType_Ready
int PyType_Ready(PyTypeObject* )
- Py_DECREF
void Py_DECREF(PyObject* op)
Used to decrement reference counts. Calls the object's deallocator function
when the refcount falls to 0; for objects that don't contain references to
other objects or heap memory this can be the standard function free().
Can be used wherever a void expression is allowed. The argument must not be a
NULL pointer. If it may be NULL, use Py_XDECREF instead.
- Py_DecRef
void Py_DecRef(PyObject* )
These are provided as conveniences to Python runtime embedders, so that
they can have object code that is not dependent on Python compilation flags.
- Py_INCREF
auto Py_INCREF(T op)
Increment reference counts. Can be used wherever a void expression is allowed.
The argument must not be a NULL pointer. If it may be NULL, use
Py_XINCREF instead.
- Py_IncRef
void Py_IncRef(PyObject* )
These are provided as conveniences to Python runtime embedders, so that
they can have object code that is not dependent on Python compilation flags.
- Py_None
Borrowed!PyObject* Py_None()
Undocumented in source. Be warned that the author may not have intended to support it.
- Py_REFCNT
auto Py_REFCNT(T* ob)
- Py_ReprEnter
int Py_ReprEnter(PyObject* )
- Py_ReprLeave
void Py_ReprLeave(PyObject* )
Helpers for printing recursive container types
- Py_SET_REFCNT
void Py_SET_REFCNT(T* ob, int refcnt)
- Py_SET_SIZE
void Py_SET_SIZE(T* ob, Py_ssize_t size)
- Py_SET_TYPE
void Py_SET_TYPE(T* ob, PyTypeObject* tipo)
Not part of the python api, but annoying to do without.
- Py_SIZE
auto Py_SIZE(T* ob)
- Py_TYPE
auto Py_TYPE(T* ob)
- Py_XDECREF
void Py_XDECREF(PyObject* op)
Same as Py_DECREF, except is a no-op if op is null.
- Py_XINCREF
auto Py_XINCREF(T op)
Increment reference counts. Can be used wherever a void expression is allowed.
The argument may be a NULL pointer.
- _PyObject_LookupSpecial
PyObject* _PyObject_LookupSpecial(PyObject* , char* , PyObject** )
- _PyObject_Str
PyObject* _PyObject_Str(PyObject* )
Availability: 2.5, 2.6, 2.7
- _PyType_CalculateMetaclass
PyTypeObject* _PyType_CalculateMetaclass(PyTypeObject* , PyObject* )
- _PyType_Lookup
PyObject* _PyType_Lookup(PyTypeObject* , PyObject* )
- _Py_BreakPoint
void _Py_BreakPoint()
- _Py_Dealloc
void _Py_Dealloc(PyObject* )
- _Py_HashDouble
Py_hash_t _Py_HashDouble(double )
- _Py_HashPointer
Py_hash_t _Py_HashPointer(void* )
- _Py_NewReference
void _Py_NewReference(PyObject* op)
Initializes reference counts to 1, and
in special builds (Py_REF_DEBUG, Py_TRACE_REFS) performs additional
bookkeeping appropriate to the special build.
- borrowed
Borrowed!T* borrowed(T* obj)
Convert a python reference to borrowed reference.
(Not part of Python api)
- PyBUF_ANY_CONTIGUOUS
enum PyBUF_ANY_CONTIGUOUS;
- PyBUF_CONTIG
enum PyBUF_CONTIG;
- PyBUF_CONTIG_RO
enum PyBUF_CONTIG_RO;
- PyBUF_C_CONTIGUOUS
enum PyBUF_C_CONTIGUOUS;
- PyBUF_FORMAT
enum PyBUF_FORMAT;
- PyBUF_FULL
enum PyBUF_FULL;
- PyBUF_FULL_RO
enum PyBUF_FULL_RO;
- PyBUF_F_CONTIGUOUS
enum PyBUF_F_CONTIGUOUS;
- PyBUF_INDIRECT
enum PyBUF_INDIRECT;
- PyBUF_ND
enum PyBUF_ND;
- PyBUF_READ
enum PyBUF_READ;
- PyBUF_RECORDS
enum PyBUF_RECORDS;
- PyBUF_RECORDS_RO
enum PyBUF_RECORDS_RO;
- PyBUF_SHADOW
enum PyBUF_SHADOW;
Flags for getting buffers Availability: >= 2.6
- PyBUF_SIMPLE
enum PyBUF_SIMPLE;
- PyBUF_STRIDED
enum PyBUF_STRIDED;
- PyBUF_STRIDED_RO
enum PyBUF_STRIDED_RO;
- PyBUF_STRIDES
enum PyBUF_STRIDES;
- PyBUF_WRITABLE
enum PyBUF_WRITABLE;
- PyBUF_WRITE
enum PyBUF_WRITE;
- PyBUF_WRITEABLE
enum PyBUF_WRITEABLE;
Flags for getting buffers Availability: >= 2.6
- Py_EQ
enum Py_EQ;
- Py_GE
enum Py_GE;
- Py_GT
enum Py_GT;
- Py_LE
enum Py_LE;
- Py_LT
enum Py_LT;
- Py_NE
enum Py_NE;
- Py_TPFLAGS_BASE_EXC_SUBCLASS
enum Py_TPFLAGS_BASE_EXC_SUBCLASS;
These flags are used to determine if a type is a subclass. Availability: >= 2.6
- Py_TPFLAGS_BYTES_SUBCLASS
enum Py_TPFLAGS_BYTES_SUBCLASS;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
- Py_TPFLAGS_DEFAULT
enum Py_TPFLAGS_DEFAULT;
- Py_TPFLAGS_DEFAULT
enum Py_TPFLAGS_DEFAULT;
- Py_TPFLAGS_DEFAULT_EXTERNAL
enum Py_TPFLAGS_DEFAULT_EXTERNAL;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
- Py_TPFLAGS_DICT_SUBCLASS
enum Py_TPFLAGS_DICT_SUBCLASS;
These flags are used to determine if a type is a subclass. Availability: >= 2.6
- Py_TPFLAGS_HAVE_INDEX
enum Py_TPFLAGS_HAVE_INDEX;
Objects support nb_index in PyNumberMethods Availability: 2.*
- Py_TPFLAGS_HAVE_NEWBUFFER
enum Py_TPFLAGS_HAVE_NEWBUFFER;
Has the new buffer protocol Availability: 2.6,2.7
- Py_TPFLAGS_HAVE_VERSION_TAG
enum Py_TPFLAGS_HAVE_VERSION_TAG;
Objects support type attribute cache Availability: >= 2.6
- Py_TPFLAGS_INT_SUBCLASS
enum Py_TPFLAGS_INT_SUBCLASS;
These flags are used to determine if a type is a subclass. Availability: >= 2.6
- Py_TPFLAGS_IS_ABSTRACT
enum Py_TPFLAGS_IS_ABSTRACT;
Type is abstract and cannot be instantiated Availability: >= 2.6
- Py_TPFLAGS_LIST_SUBCLASS
enum Py_TPFLAGS_LIST_SUBCLASS;
- Py_TPFLAGS_LONG_SUBCLASS
enum Py_TPFLAGS_LONG_SUBCLASS;
These flags are used to determine if a type is a subclass. Availability: >= 2.6
- Py_TPFLAGS_STRING_SUBCLASS
enum Py_TPFLAGS_STRING_SUBCLASS;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
- Py_TPFLAGS_TUPLE_SUBCLASS
enum Py_TPFLAGS_TUPLE_SUBCLASS;
- Py_TPFLAGS_TYPE_SUBCLASS
enum Py_TPFLAGS_TYPE_SUBCLASS;
- Py_TPFLAGS_UNICODE_SUBCLASS
enum Py_TPFLAGS_UNICODE_SUBCLASS;
These flags are used to determine if a type is a subclass. Availability: >= 2.6
- Py_TPFLAGS_VALID_VERSION_TAG
enum Py_TPFLAGS_VALID_VERSION_TAG;
Objects support type attribute cache Availability: >= 2.6
Mirror object.h
Object and type object interface
Objects are structures allocated on the heap. Special rules apply to the use of objects to ensure they are properly garbage-collected. Objects are never allocated statically or on the stack; they must be accessed through special macros and functions only. (Type objects are exceptions to the first rule; the standard types are represented by statically initialized type objects, although work on type/class unification for Python 2.2 made it possible to have heap-allocated type objects too).
An object has a 'reference count' that is increased or decreased when a pointer to the object is copied or deleted; when the reference count reaches zero there are no references to the object left and it can be removed from the heap.
An object has a 'type' that determines what it represents and what kind of data it contains. An object's type is fixed when it is created. Types themselves are represented as objects; an object contains a pointer to the corresponding type object. The type itself has a type pointer pointing to the object representing the type 'type', which contains a pointer to itself!).
Objects do not float around in memory; once allocated an object keeps the same size and address. Objects that must hold variable-size data can contain pointers to variable-size parts of the object. Not all objects of the same type have the same size; but the size cannot change after allocation. (These restrictions are made so a reference to an object can be simply a pointer -- moving an object would require updating all the pointers, and changing an object's size would require moving it if there was another object right next to it.)
Objects are always accessed through pointers of the type 'PyObject *'. The type 'PyObject' is a structure that only contains the reference count and the type pointer. The actual memory allocated for an object contains other data that can only be accessed after casting the pointer to a pointer to a longer structure type. This longer type must start with the reference count and type fields; the macro PyObject_HEAD should be used for this (to accommodate for future changes). The implementation of a particular object type can cast the object pointer to the proper type and back.
A standard interface exists for objects that contain an array of items whose size is determined when the object is allocated.