Stefan Behnel added the comment:

In fact, I did consider it and I'd love to, but it's not something to do 
lightly because the semantics would be a bit fuzzy and unsafe. Basically, 
extension types that have only Python object compatible attributes could 
automatically pickle, but as soon as you add, say, a C pointer attribute, it 
would fail to pickle at runtime, maybe even without an error (as in the case at 
hand). And what do you think, how many users write unit tests for pickling all 
of their extension types?

Imagine the case that Cython adds automatic pickling support for a base class 
and a user tries to implement pickling in a subclass, but using a different set 
of pickle support methods. It might then happen that the user implementation is 
silently ignored by the pickle implementation because it prefers the methods in 
the base class. The user might not even notice this because it (mostly) seems 
to work. And now think of the case where this user code exists already and 
Cython starts to enable the base class pickle support with a new release and 
overrides the user implementation. That might lead to seriously difficult to 
find bugs.

It would be great to make this support the default rather than requiring user 
interaction (say, a class decorator or compiler directive), but the subtle code 
breakage cases above sadly suggest otherwise...

Anyway, this needs more thinking and this ticket isn't the right place to do 
that.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22995>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to