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

WIP: Optionally use pickle5 #364

Closed
wants to merge 11 commits into from

Conversation

jakirkham
Copy link
Member

Fixes #179

Optionally uses pickle5 in cloudpickle.

@jakirkham
Copy link
Member Author

Before doing more work here, would be curious to get people's thoughts on this approach 🙂

Does this generally seem reasonable? Or would we want to approach this in a different way?

@pierreglaser
Copy link
Member

Before doing more work here, would be curious to get people's thoughts on this approach

The general approach (optionally rely on pickle5) looks good to me. We should also add/modify an entry in the CI to test cloudpickle against Python < 3.8 and pickle5. Thanks @jakirkham!

jakirkham added 3 commits May 10, 2020 20:38
Tries to use `pickle5` for `pickle` if available on older Python
versions.
@codecov
Copy link

codecov bot commented May 11, 2020

Codecov Report

Merging #364 into master will decrease coverage by 33.00%.
The diff coverage is 45.45%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #364       +/-   ##
===========================================
- Coverage   92.95%   59.95%   -33.01%     
===========================================
  Files           2        3        +1     
  Lines         809      824       +15     
  Branches      164      168        +4     
===========================================
- Hits          752      494      -258     
- Misses         29      313      +284     
+ Partials       28       17       -11     
Impacted Files Coverage Δ
cloudpickle/compat.py 30.00% <30.00%> (ø)
cloudpickle/cloudpickle_fast.py 93.72% <50.00%> (-2.01%) ⬇️
cloudpickle/cloudpickle.py 46.43% <100.00%> (-45.40%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 70dc1df...8c6518b. Read the comment docs.

jakirkham added 7 commits May 10, 2020 20:57
It seems `pickle5` doesn't include this or an alias to it. So just
import it from `pickle` directly.
As `CellType` was added in Python 3.8, it won't be available in Python
3.6 or 3.7. So check before adding it to the dispatch table.
@jakirkham
Copy link
Member Author

Have run into some test issues around CellType (added in Python 3.8) and other related things. Not sure if there is an easy way to bypass these sorts of issues (since they are not the primary focus here). Thoughts? 🙂

@pierreglaser
Copy link
Member

With regards to the types.CellType issue: cloudpickle_fast.py was originally written for Python 3.8+, so if we want to use it for Python < 3.8, we have no choice but to make the reducers within cloudpickle_fast.py cross-version.

The clean way though would be to refactor the organization of the reducers in cloudpickle, many of which are duplicated between cloudpickle.py and cloudpickle_fast.py, so that both modules import the same ones. See #284. Maybe this PR is a good occasion to do this (within this PR or separately) :)

@ogrisel
Copy link
Contributor

ogrisel commented May 12, 2020

If we refactor the reducers, we should make a best effort to still make it possible to unpickle older pickles.

Even if this is not part of the cloudpickle public API (see the diclaimer for the scope of the project in the README) it would be great to preserve backward compat with previous version pickles if not too costly from a maintenance / tech debt point of view.

@pierreglaser
Copy link
Member

pierreglaser commented May 13, 2020

That is a very good remark @ogrisel. Would the "deprecation" cycle I suggested in #359 (comment) work for you? IMHO it achieves a good tradeoff between all the stakes (code complexity, user friendliness, contract of cloudpickle...)

@ogrisel
Copy link
Contributor

ogrisel commented May 14, 2020

+1 for deprecation warnings when possible.

@jakirkham
Copy link
Member Author

Closing as this has been superseded by PR ( #370 ).

@jakirkham jakirkham closed this May 29, 2020
@jakirkham jakirkham deleted the opt_use_pickle5 branch May 29, 2020 22:42
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 this pull request may close these issues.

cloudpickle could extend pickle5
3 participants