[ZODB-Dev] persisting "immutable" classes

Tim Peters tim at zope.com
Sat Feb 28 20:31:36 EST 2004


[John Belmonte]
> ...
>    * as an optimal solution, given that tens of thousands of these
> keys may exist, use a second-class object with slots (by defining my
> own get/setstate)

It's unclear why you need your own {get,set)state functions.  Automagic
pickle support for new-style objects with __slots__ was added in Python 2.3,
as described (in excruciating detail) here:

    http://www.python.org/peps/pep-0307.html

The magical __slots__ support requires using the new-in-2.3 "pickle protocol
2"; that protocol also allows pickle to do lots of other things in better
ways for new-style classes.




More information about the ZODB-Dev mailing list