Pickling fast_callable wrappers

asked 2021-04-13 22:39:11 +0100

step gravatar image

I am trying to parallelize a code that must evaluate a specific function on several different inputs.

The function is obtained by taking a (really big) symbolic expression and calling the method fast_callable on it. Now, what I need to do is to "describe" the function to all the compute nodes. Unfortunately, I can not find a way to pickle the wrapper that fast_callable returns.

Indeed, if I try the following

from pickle import dumps
a = x^2 + 3 * x
b = fast_callable(a, vars=(x,))
dumps(b)

I get

TypeError: cannot pickle 'sage.ext.interpreters.wrapper_py.Wrapper_py' object

I have tried with pickle, with cPickle, with dill and with SagePickler, with no luck. Is there any way to export the callable objects? Otherwise, is there an easy workaround for this? The only one that I come out with would be to pass the symbolic expression instead of passing the output of fast_callable but, taking into account that it takes more that 15 minutes to execute the fast_callable function on my symbolic expression, this will neglect any improvement that I get from parallelizing my code.

edit retag flag offensive close merge delete

Comments

I have seen that there is a question that is somehow related to mine: http://ask.sagemath.org/question/9831.... Unfortunately, I can not follow the answer that is reported there (compile the code in C using sympy) because I need to use MPFR to increase the precision of my results

step gravatar imagestep ( 2021-04-14 00:23:36 +0100 )edit