Type | Defined in | Information | C | G | P | S |
---|---|---|---|---|---|---|
bool | Represented as an int. | Yes | Yes | Yes | Yes | |
buffer | Objects/bufferobject.c | Yes | Yes | Yes | No | |
cell | Include/cellobject.h. | Yes | Yes | Yes | No | |
classobj | Include/classobject.h | Yes | Yes | Yes | No | |
instance | Include/classobject.h | Yes | Yes | Yes | No | |
instancemethod | Include/classobject.h | Yes | Yes | Yes | No | |
PyCObject | Objects/cobject.c | Wraps arbitrary C data. Seems impossible to count. | No | No | No | No |
complex | Include/complexobject.h | Yes | Yes | Yes | Yes | |
*_descriptor | Include/descrobject.h | Looks very annoying to count. Contains C functions. It should be possible to count partly, though. | No | No | No | No |
dictproxy | Objects/descrobject.c | Yes | Yes | Yes | No | |
method-wrapper | Objects/descrobject.c | Yes | Yes | Yes | No | |
property | Objects/descrobject.c | Yes | Yes | Yes | No | |
dict | Include/dictobject.h | Code depends on representation and PyDict_MINSIZE. | Yes | Yes | No | No |
dict-itemiterator | Objects/dictobject.c | Returned from dict.iteritems(). Code contains a direct copy of dictiterobject from dictobject.c! Doesn't work in Python 2.3. | Yes | No | Yes | No |
dict-keyiterator | Objects/dictobject.c | Returned from dict.iterkeys(). Code contains a direct copy of dictiterobject from dictobject.c! Doesn't work in Python 2.3. | Yes | No | Yes | No |
dict-valueiterator | Objects/dictobject.c | Returned from dict.itervalues(). Code contains a direct copy of dictiterobject from dictobject.c! Doesn't work in Python 2.3. | Yes | No | Yes | No |
enumerate | Objects/enumobject.c | Yes | Yes | Yes | No | |
file | Include/fileobject.h | Counted by Pyrex code, apart from stdio internals, of course. | Yes | No | No | No |
float | Include/floatobject.h | Yes | Yes | Yes | Yes | |
frame | Include/frameobject.h | Carries an additional f_code.co_stacksize words of data (the stack). | Yes | Yes | No | No |
function | Include/funcobject.h | Yes | Yes | Yes | No | |
classmethod | Objects/funcobject.c | Yes | Yes | Yes | No | |
staticmethod | Objects/funcobject.c | Yes | Yes | Yes | No | |
generator | Include/genobject.h | Yes | Yes | Yes | No | |
int | Include/intobject.h | Yes | Yes | Yes | Yes | |
iterator | Objects/iterobject.c | Yes | Yes | Yes | No | |
callable-iterator | Objects/iterobject.c | Yes | Yes | Yes | No | |
list | Include/listobject.h | Counting code depends on representation of list as array of PyObject*. | Yes | Yes | No | No |
listiterator | Objects/listobject.c | Yes | Yes | Yes | No | |
listreverseiterator | Objects/listobject.c | Yes | Yes | Yes | No | |
long | Include/longintrepr.h | Counted by utils.c. | Yes | Yes | No | No |
builtin_function_or_method | Include/methodobject.h | Just about impossible to count - it represents a built-in function. It contains a PyMethodDef* which could be counted, though the size of the table will probably be negligible compared to the size of the functions. | No | Yes | No | No |
module | Objects/moduleobject.c | Very nice for such an important type. Just contains a dict. | Yes | Yes | Yes | No |
NoneType | Objects/object.c | Yes | Yes | Yes | Yes | |
NotImplementedType | Objects/object.c | Yes | Yes | Yes | Yes | |
xrange | Objects/rangeobject.c | Yes | Yes | Yes | Yes | |
set, frozenset | Include/setobject.h | Similar representation to dict. Code depends on representation and PySet_MINSIZE. | Yes | No | No | No |
ellipsis | Objects/sliceobject.c | Yes | Yes | Yes | Yes | |
slice | Include/sliceobject.h | Yes | No | Yes | No | |
basestring | Objects/stringobject.c | Yes | Yes | Yes | Yes | |
str | Include/stringobject.h | Code depends on representation as variable-size object. | Yes | Yes | No | No |
structseq | Include/structseq.h | Not a real type, despite appearances :-) | N/A | N/A | N/A | N/A |
tuple | Include/tupleobject.h | Code depends on representation as variable-size object. | Yes | Yes | No | No |
tupleiterator | Objects/tupleobject.c | Yes | Yes | Yes | Yes | |
type | Include/object.h | Terribly hairy to count. It's not done yet. It might be impossible. Luckily it tells the GC about its fields. | No | Yes | No | No |
object | Include/object.h | Only references its type. That's counted. | Yes | No | No | No |
super | Objects/typeobject.c | Yes | Yes | Yes | No | |
unicode | Include/unicodeobject.h | Sets __itemsize__ == 0, so the code uses 2 instead. Can contain a string-encoded version of itself which is counted by code in utils.c. | Yes | No | No | No |
weakref, weakproxy, weakcallableproxy | Include/weakrefobject.h | All behave nicely. | Yes | Yes | Yes | No |
code | Include/compile.h | Eek, I made a mistake with this and thought it talked to the GC. | Yes | No | Yes | No |
symtable entry | Include/symtable.h | Yes, the type name has a space in it! It looks like it co-operates with the GC, so should work nicely. | Yes | Yes | No | No |
traceback | Include/traceback.h | Yes | Yes | Yes | No |
Look in sizes.samples. You might need to run test2.test() first.
type.__dict__
[].__len__
Call dict object's iteritems(), iterkeys() and itervalues() methods respectively.
Define:
class A(object): def __getitem__(self, val): pass
and call iter(A()).
iter(l) where l is a list.
reversed(l) where l is a list.
iter(t) where t is a tuple.
This is a list of all types in the core interpreter. It's the edited output of grep PyTypeObject Objects/* Python/*.
Objects/boolobject.c:PyTypeObject PyBool_Type = { Objects/bufferobject.c:PyTypeObject PyBuffer_Type = { Objects/cellobject.c:PyTypeObject PyCell_Type = { Objects/classobject.c:PyTypeObject PyClass_Type = { Objects/classobject.c:PyTypeObject PyInstance_Type = { Objects/classobject.c:PyTypeObject PyMethod_Type = { Objects/cobject.c:PyTypeObject PyCObject_Type = { Objects/complexobject.c:PyTypeObject PyComplex_Type = { Objects/descrobject.c:static PyTypeObject PyMethodDescr_Type = { Objects/descrobject.c:static PyTypeObject PyClassMethodDescr_Type = { Objects/descrobject.c:static PyTypeObject PyMemberDescr_Type = { Objects/descrobject.c:static PyTypeObject PyGetSetDescr_Type = { Objects/descrobject.c:PyTypeObject PyWrapperDescr_Type = { Objects/descrobject.c:static PyTypeObject proxytype = { Objects/descrobject.c:static PyTypeObject wrappertype = { Objects/descrobject.c:PyTypeObject PyProperty_Type = { Objects/dictobject.c:PyTypeObject PyDict_Type = { Objects/dictobject.c:PyTypeObject PyDictIterKey_Type = { Objects/dictobject.c:PyTypeObject PyDictIterValue_Type = { Objects/dictobject.c:PyTypeObject PyDictIterItem_Type = { Objects/enumobject.c:PyTypeObject PyEnum_Type = { Objects/enumobject.c:PyTypeObject PyReversed_Type = { Objects/fileobject.c:PyTypeObject PyFile_Type = { Objects/floatobject.c:PyTypeObject PyFloat_Type = { Objects/frameobject.c:PyTypeObject PyFrame_Type = { Objects/funcobject.c:PyTypeObject PyFunction_Type = { Objects/funcobject.c:PyTypeObject PyClassMethod_Type = { Objects/funcobject.c:PyTypeObject PyStaticMethod_Type = { Objects/genobject.c:PyTypeObject PyGen_Type = { Objects/intobject.c:PyTypeObject PyInt_Type = { Objects/iterobject.c:PyTypeObject PySeqIter_Type = { Objects/iterobject.c:PyTypeObject PyCallIter_Type = { Objects/listobject.c:static PyTypeObject sortwrapper_type = { Objects/listobject.c:static PyTypeObject cmpwrapper_type = { Objects/listobject.c:PyTypeObject PyList_Type = { Objects/listobject.c:PyTypeObject PyListIter_Type; Objects/listobject.c:PyTypeObject PyListIter_Type = { Objects/listobject.c:PyTypeObject PyListRevIter_Type; Objects/listobject.c:PyTypeObject PyListRevIter_Type = { Objects/longobject.c:PyTypeObject PyLong_Type = { Objects/methodobject.c:PyTypeObject PyCFunction_Type = { Objects/moduleobject.c:PyTypeObject PyModule_Type = { Objects/object.c:static PyTypeObject PyNone_Type = { Objects/object.c:static PyTypeObject PyNotImplemented_Type = { Objects/rangeobject.c:PyTypeObject PyRange_Type = { Objects/setobject.c:PyTypeObject PySet_Type = { Objects/setobject.c:PyTypeObject PyFrozenSet_Type = { Objects/sliceobject.c:static PyTypeObject PyEllipsis_Type = { Objects/sliceobject.c:PyTypeObject PySlice_Type = { Objects/stringobject.c:PyTypeObject PyBaseString_Type = { Objects/stringobject.c:PyTypeObject PyString_Type = { Objects/structseq.c:static PyTypeObject _struct_sequence_template = { Objects/tupleobject.c:PyTypeObject PyTuple_Type = { Objects/tupleobject.c:PyTypeObject PyTupleIter_Type; Objects/tupleobject.c:PyTypeObject PyTupleIter_Type = { Objects/typeobject.c:PyTypeObject PyType_Type = { Objects/typeobject.c:PyTypeObject PyBaseObject_Type = { Objects/typeobject.c:PyTypeObject PySuper_Type = { Objects/unicodeobject.c:PyTypeObject PyUnicode_Type = { Objects/weakrefobject.c:PyTypeObject _PyWeakref_RefType = { Objects/weakrefobject.c:PyTypeObject _PyWeakref_ProxyType = { Objects/weakrefobject.c:PyTypeObject _PyWeakref_CallableProxyType = { Python/compile.c:PyTypeObject PyCode_Type = { Python/symtable.c:PyTypeObject PySymtableEntry_Type = { Python/traceback.c:PyTypeObject PyTraceBack_Type = {