O'Reilly logo

Python Essential Reference, Second Edition by David M Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Special Methods for Types

This section describes the C data structures used to implement types. This is an advanced topic and the presentation here is only intended to be a quick reference.

Types are defined by a structure with the following fields. Many of the fields in this structures use typedef names such as hashfunc, binaryfunc, intargfunc, and so forth. These types are defined later in this appendix in Table B.26.

 typedef struct _typeobject { PyObject_VAR_HEAD char *tp_name; int tp_basicsize; int tp_itemsize; destructor tp_dealloc; printfunc tp_print; getattrfunc tp_getattr; setattrfunc tp_setattr; cmpfunc tp_compare; reprfunc tp_repr; PyNumberMethods *tp_as_number; PySequenceMethods *tp_as_sequence; PyMappingMethods *tp_as_mapping; hashfunc ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required