symengine.py
symengine.py copied to clipboard
Directly expose serialization function
It would be really nice if the serialization functions used internally by the pickle support were exposed as direct functions. Basically I have a use case where I'd like to serialize the raw parameter expressions without using pickle. I can implement this currently by doing something like:
import symengine
from symengine.lib.symengine_wrapper import load_basic
input_expression = symengine.Symbol('x') * 2
data = input_expression.__reduce__()[1][0]
loaded_expression = load_basic(data)
But it feels weird to use explicitly internal functions and dunders like this to get the serialization like this. It would be great if there were public functions exposed to do this.
I'd be glad to contribute this if it's something that people agree with.
Sure. A corresponding save_basic makes sense.