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

DM-19616: Add patch to support pickle/unpickle for multiprocessing #5

Merged
merged 2 commits into from Jun 20, 2019

Conversation

parejkoj
Copy link
Contributor

No description provided.


+ def test_pickle(self):
+ h = htm.HTM(5)
+ pickled = pickle.dumps(h, protocol=pickle.HIGHEST_PROTOCOL)
Copy link

Choose a reason for hiding this comment

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

Why HIGHEST_PROTOCOL? I'm guessing (without having looked at the meas_algorithms code) that this would usually be called without a protocol argument, so it's probably most useful to test DEFAULT_PROTOCOL instead (or even range(HIGHEST_PROTOCOL+1) or something).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

HIGHEST_PROTOCOL results in much smaller and faster pickling, and is purely a pickle-internals thing; the pickle infrastructure here doesn't know or care about it. Though, in this case it shouldn't matter, since the only thing being pickled is an int and a function pointer. meas_algorithms doesn't do any pickling itself, multiprocessing does, and it would almost certainly use the best protocol for that.

Choose a reason for hiding this comment

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

Multiprocessing uses the default protocol: https://github.com/python/cpython/blob/master/Lib/multiprocessing/reduction.py#L49

Just seems weird to force the test to use something else without explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh. I'm quite surprised they use the default there: I would have expected HIGHEST, because it's purely in-memory. Ah well, at least DEFAULT is now 3, which is good enough. I've removed the explicit protocol.

@parejkoj parejkoj merged commit abf0df1 into master Jun 20, 2019
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.

None yet

3 participants