Cantera / enhancements

Repository for proposed and ongoing enhancements to Cantera
11 stars 5 forks source link

Make SolutionArray picklable #162

Open ischoegl opened 1 year ago

ischoegl commented 1 year ago

Abstract

After refactoring of SolutionArray in Cantera/cantera#1426 (and Cantera/cantera#1458), there is still the option of making the object picklable in Python (similar to Cantera/cantera#692). An implementation is deferred, as it is unclear how common use cases would be.

The implementation itself would be straight-forward: modify C++ SolutionArray::save/restore to allow for YAML string output/input, and implement Python SolutionArray.__getstate__/__getstate__.

rwest commented 1 year ago

In general having things be pickleable is nice, especially for some parallelization and workflow tools that rely on it

ischoegl commented 1 year ago

In general having things be pickleable is nice, especially for some parallelization and workflow tools that rely on it

Thanks for the comment. I generally agree, and have implemented Cantera/cantera#692 for that reason. Pickled SolutionArray objects may be a good way to pass back results from multiprocessing pools. I don’t have an urgent need for this at the moment myself, but if anyone else wants to take this on I’d be more than happy to assist with a PR.