On May 27, 2008, at 2:27 PM, Lisandro Dalcin wrote:
> On 5/27/08, Eric Jonas <[EMAIL PROTECTED]> wrote:
>> To start with, this is awesome. Thank you so much!
>>
>> Next question: What if I want MyPair to have a zero-argument
>> constructor? (Well, besides self, that is). If I do:
>>
>> class MyPair(pair):
>> def __init__(self):
>> pass
>>
>> then I get "TypeError: ('__init__() takes exactly 1 argument (3
>> given)".
>> Does this mean that derived types must always have constructors
>> with the
>> same number (or more) than their base type?
>
> Yes and No. The problem is that different pickle protocols assume and
> do different things. Give me some minute, I'll try to figure out
> what's going on. And yes, you are right, this is a real crap if you
> want so support in a easy way all pickle protocols, plus class
> inheritance.
On this note, I think Cython should be able to provide a default
__reduce__ that will "just work" for cdef classes, the way normal
pickling works in Python without having to think about it. Of course,
one should always be able to override it manually, and if the class
has specially-typed members than it may take a bit more work.
- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev