[Python-Dev] How to suppress instance __dict__?
David Abrahams
dave@boost-consulting.com
Sat, 22 Mar 2003 18:25:00 -0500
I am generating extension types derived from a type which is derived
from int 'int' by calling the metaclass; in order to prevent instances
of the most-derived type from getting an instance __dict__ I am
putting an empty tuple in the class __dict__ as '__slots__'. The
problem with this hack is that it disables pickling of these babies:
"a class that defines __slots__ without defining __getstate__
cannot be pickled"
Yes, I can define __getstate__, __setstate__, and __getinitargs__ (the
only one that can actually do any work, since ints are immutable),
but I was wondering if there's a more straightforward way to suppress
the instance __dict__ in the derived classes.
TIA,
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com