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

Marius Gedminas marius at gedmin.as
Wed May 27 12:22:56 EDT 2009


On Wed, May 27, 2009 at 03:35:26PM +0200, Hanno Schlichting wrote:
> 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.

It's an Internet Law that every correction must have at least one
mistake.  Mine was assuming that __new__ is always invoked.

> > 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__".

Marius Gedminas
-- 
Bumper sticker: No radio - Already stolen.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zodb-dev/attachments/20090527/5961b877/attachment.bin 


More information about the ZODB-Dev mailing list