-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cython-Python pickling #171
Comments
There are protocols 0..4 (inclusive). Maybe I could bump upper range in these places? ps after mentioned +1 number of tests turn from 36 to 44. And they pass |
Regarding the issue itself.. |
My idea is to look on CPython sources. |
Here is what I got playing around with special methods related to pickle protocol: import pickle
USE_CYTHON = True
# USE_CYTHON = False
class A:
def __getnewargs_ex__(self):
# print('in __getnewargs_ex__ of A')
if USE_CYTHON:
print('selecting path B')
return ((B,), {})
else:
print('selecting path A')
return ((A,), {})
def __new__(cls, *args, **kwargs):
# print('In A __new__, *args, **kwargs: ', *args, **kwargs)
if args:
return args[0]()
else:
return super().__new__(cls)
class B: pass
if __name__ == '__main__':
obj = A()
pd = pickle.dumps(obj)
pl = pickle.loads(pd)
# USE_CYTHON = True USE_CYTHON = False
print(pl.__class__) # <class '__main__.B'> or <class '__main__.A'> |
Pickled pure Python MultiDicts should be unpickled as Cythonized if unpicker is executed on machine with Cython support.
And vise versa.
The text was updated successfully, but these errors were encountered: