Extension type inherit from Python int
Mathias Enzensberger
menz123 at me.com
Thu Jan 16 12:33:06 EST 2020
Hello,
I am trying to write an extension type that inherits from Pythons int.
Based on the documentation,
<https://docs.python.org/3/extending/newtypes_tutorial.html#subclassing-other-types>
this should be possible, but I checked Pythons implementation and the
struct defining a PyLongObject uses a flexible array to store the limbs
to support arbitrary large numbers. So having a PyLongObject as first
member of my own types struct doesn't work because parts of the
ob_digit array would be overwritten by members defined in the subclass
of the new type that inherits from PyLongObject.
Has anyone already done something like that? Is there some trick to
work around that issue, or is it simply not possible to inherit from
PyLongObject?
Thank you,
Mathias
More information about the Python-list
mailing list