Extension type inherit from Python int

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Jan 17 00:05:57 EST 2020


On 17/01/20 11:12 am, Random832 wrote:
> 
> pure-python types that derive from int place __dict__ at the end of
> the object, I don't know if it's possible for you to do the same with
> the fields you intend to add (for some reason it isn't done with
> __slots__), but if all else fails you could do the same and store
> whatever data you need in the dict.

Or make the C code that accesses the data smart enough to find
where the int data ends and work from there.

But this is getting messy enough that at this point I would
stop and ask myself if it *really* needs to derive from int,
or whether it just needs to be something with a sufficiently
int-like interface.

-- 
Greg



More information about the Python-list mailing list