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

implement __getstate__ and __setstate__ for PySINumber and PySIArrayX #43

Merged
merged 1 commit into from
Jan 10, 2022

Conversation

prehner
Copy link
Contributor

@prehner prehner commented Dec 26, 2021

This allows the python objects to be pickled and sent across different processes, e.g.:

from concurrent.futures import ProcessPoolExecutor
from si_units import *

def f(x):
    return SIArray1.linspace(x,2*x,11)

with ProcessPoolExecutor() as ex:
    result = list(ex.map(f, [KELVIN, BAR, PASCAL]))
result
[[1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7000000000000002, 1.8, 1.9, 2] K,
 [100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, 180000, 190000, 200000] Pa,
 [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7000000000000002, 1.8, 1.9, 2] Pa]

@prehner prehner merged commit 568d59a into master Jan 10, 2022
@prehner prehner deleted the pickle branch January 10, 2022 10:30
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.

1 participant