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 Patch pickleable #2498

Merged
merged 4 commits into from
Apr 11, 2023
Merged

Make Patch pickleable #2498

merged 4 commits into from
Apr 11, 2023

Conversation

joouha
Copy link
Contributor

@joouha joouha commented Apr 5, 2023

Hello,

This makes Patch objects picklable by adding __getstate__ and __setstate__ methods.

This allows caching of callbacks which return Patch objects.

Currently pickling Patch objects results in a TypeError("'Patch' object is not callable") exception.

Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

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

💃 Looks good, thank you.

Can you add a changelog entry?

The failing tests in renderer seems unrelated

@joouha
Copy link
Contributor Author

joouha commented Apr 5, 2023

Done!

@alexcjohnson
Copy link
Collaborator

Oh interesting - is this for using Patch in a background callback? Or is there some other reason to pickle it?

@joouha
Copy link
Contributor Author

joouha commented Apr 5, 2023

@alexcjohnson My use case is simply so I can cache the result of a callback (as per the memoization example in the docs) - this was failing if the callback returned a Patch.

But I guess this would also allow background callbacks to return Patches too :-)

@T4rk1n T4rk1n merged commit 093b559 into plotly:dev Apr 11, 2023
@joouha joouha deleted the pickleable-patch branch April 11, 2023 16:10
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.

3 participants