Skip to content
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

make cloudpickle and cloudpickle_fast use the same reducers. #284

Closed
pierreglaser opened this issue Jun 10, 2019 · 0 comments · Fixed by #368
Closed

make cloudpickle and cloudpickle_fast use the same reducers. #284

pierreglaser opened this issue Jun 10, 2019 · 0 comments · Fixed by #368

Comments

@pierreglaser
Copy link
Member

cloudpickle and cloudpickle_fast differ in the sense that the cloudpickle_fast's CloudPickler only has to reduce objects (the actual saving is taken care of by logic coded in the pickle.Pickler class), whereas the cloudpickle.CloudPickler reduces AND saves objects in one single method (save_{object_type}(self, obj))

Right now, the cloudpickle.CloudPickler reducing parts of the save_{object_type} methods do not use the reduce_{object_type} reducers implemented in cloudpickle_fast.
To avoid the need to write twice any change we make to a reducer, it would be great to refactor most cloudpickle.CloudPickler.save_* methods, to make them look like this

def save_{object_type}(self, obj):
    rv = reduce_{object_type}(obj)
    self.save_reduce(*rv, obj=obj)

reduce_{object_type} being used both by cloudpickle and cloudpickle_fast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant