Chris Withers wrote:
> Hanno Schlichting wrote:
>> Nope. DateTime objects are plain old-style classes and don't inherit
>> from persistent.*. 
> Hmm, oh well, my bad...
> In that case it must just be that their pickled form is huge compared to 
> an int ;-)


len(cPickle.dumps(DateTime.DateTime(), 1)) == 392

Where as their float representation is:

len(cPickle.dumps(DateTime.DateTime().timeTime(), 1)) == 10

> They are incredibly expensive to unpickle since all
>> the DWIM magic in their __init__ get called each time, though.
> How come? Unpickling doesn't call __init__ and I don't see why the DWIM 
> magic would be needed anyway, since everything has already been parsed.

How would a new instance of a class be constructed without calling the
init or new? Look at the _instantiate method in, when it does:

value = klass(*args)

What happens on unpickling is that a new DateTime instance representing
"just now" is generated and then that instance is updated with the
values from the pickle.


For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -

Reply via email to