[ZODB-Dev] URGENT: ZODB down - Important Software Application at CERN

Hanno Schlichting hannosch at hannosch.eu
Wed May 27 09:35:26 EDT 2009


Marius Gedminas wrote:
> On Wed, May 27, 2009 at 12:17:36PM +0200, Hanno Schlichting wrote:
>> Chris Withers wrote:
>>> Hanno Schlichting wrote:
>>>> 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?
> 
> You're cleverly changing the question ;-)
> 
> *Most* objects are unpickled by calling __new__ followed by
> __setstate__, but without calling __init__.  Chris is therefore
> understandably surprised.

Hhm, no. From what I read most objects are created by the following:

class _EmptyClass:
    pass

value = _EmptyClass()
value.__class__ = klass


The "__new__" is only called when your new-style class has a
"__getnewargs__" method, which none of the standard types have. And even
then it would only be used for pickle protocol 2, but the ZODB uses
protocol 1.

> Old-style classes that define __getinitargs__ will get their __init__
> called during unpickling, though, and DateTime is such a class.

Ah, ok. I missed that this only happens in conjunction with
"__getinitargs__".

Thanks,
Hanno



More information about the ZODB-Dev mailing list