[Python-Dev] Proper initialization of structs

Alexandre Vassalotti alexandre at peadrop.com
Fri Oct 31 00:51:47 CET 2008


On Thu, Oct 30, 2008 at 6:36 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Alexandre Vassalotti wrote:
>> And that is exactly the reason why, the _pickle module doesn't use
>> __new__ for initialization.  Doing any kind of argument parsing in
>> __new__ prevents subclasses from customizing the arguments for their
>> __init__.
>
> No it doesn't - it just means the subclasses have to override __new__ as
> well and then give the parent class the arguments it needs.
>

Right, and that's what subclasses of built-in types need to do.
However for _pickle, I wanted to reduce interface differences between
the Python implementation. Perhaps, in that case, moving the content
of __init__ methods in both implementations would have been a better
choice. That would certainly make it easier to expose internal methods
easier to fix issue3385. Is it too late to change?

-- Alexandre


More information about the Python-Dev mailing list