I just read through this great tutorial:
2. Defining Extension Types: Tutorial — Python 3.10.8 documentation
I noticed that the CustomType uses PyVarObject_HEAD_INIT(NULL, 0)
instead of PyObject_HEAD_INIT(NULL, 0)
. According to the reference, PyVarObject_HEAD_INIT
is only needed for objects that have some notion of length, but the tutorial never adds a notion of length to CustomType. Would it be better for the example to use PyObject_HEAD_INIT
, or am I misunderstanding the distinction?
The final example in the tutorial, SubListType, also uses PyVarObject_HEAD_INIT(NULL, 0)
, but that makes more sense to me since it is subclassing list.