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

Pickle support #147

Merged
merged 6 commits into from
Apr 15, 2019
Merged

Pickle support #147

merged 6 commits into from
Apr 15, 2019

Conversation

AstraLuma
Copy link
Member

Add support for pickling.

@@ -156,6 +156,9 @@ def __new__(cls, *args, **kwargs):

return self

def __reduce__(self):
return type(self).__new__, (type(self), self.x, self.y)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will that prevent subclasses (esp. ones that add attributes) to be pickled correctly?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The improved test answers this positively, in the case of subclasses without extra attributes.

I guess it would make sense to punt the with-attributes case to #144.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pickle docs mention higher-level protocols, but they're not actually implemented by the core stuff? not super clear.

tests/test_vector2_ctor.py Outdated Show resolved Hide resolved
@nbraud nbraud mentioned this pull request Apr 14, 2019
tests/test_vector2_ctor.py Outdated Show resolved Hide resolved
tests/test_vector2_ctor.py Outdated Show resolved Hide resolved
nbraud and others added 2 commits April 15, 2019 16:20
@nbraud
Copy link
Collaborator

nbraud commented Apr 15, 2019

bors r+

bors bot added a commit that referenced this pull request Apr 15, 2019
147: Pickle support r=nbraud a=astronouth7303

Add support for pickling.

Co-authored-by: Jamie Bliss <jamie@ivyleav.es>
Co-authored-by: Nicolas Braud-Santoni <nicolas@braud-santoni.eu>
@bors
Copy link
Contributor

bors bot commented Apr 15, 2019

Build succeeded

  • docs
  • FreeBSD PYTHON:3.6
  • FreeBSD PYTHON:3.7
  • lint
  • Linux container:python:3.6-slim
  • Linux container:python:3.7-slim
  • macOS PYTHON:3.6.8
  • macOS PYTHON:3.7.2
  • Windows container:python:3.6-windowsservercore-1809
  • Windows container:python:3.7-windowsservercore-1809

@bors bors bot merged commit 2ce70b5 into master Apr 15, 2019
nbraud added a commit to nbraud/ppb-vector that referenced this pull request Apr 15, 2019
nbraud added a commit to nbraud/ppb-vector that referenced this pull request Apr 15, 2019
@nbraud nbraud deleted the pickle-support branch April 16, 2019 18:59
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.

2 participants