symengine.py icon indicating copy to clipboard operation
symengine.py copied to clipboard

Directly expose serialization function

Open mtreinish opened this issue 2 years ago • 1 comments

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.

mtreinish avatar Aug 24 '23 13:08 mtreinish

Sure. A corresponding save_basic makes sense.

isuruf avatar Aug 24 '23 21:08 isuruf