Imagine the process of the following three steps:
- I'm a big and somewhat Complex expression (this process takes a lot of time) using sympy to create
- Use that expression in the lambda function by using
sympy.lambdify
(also slow) Is transformed. - The function has been evaluated (fast)
Ideally, steps 1 and 2 are done only once, while step 3 evaluated multiple times Will go Unfortunately, the evaluation of step 3 spread over time (and different dragon sessions!)
I am looking for a way to save the "lambedefide" expression in the disk so that I can load them and I Unfortunately, pickle does not support lambda functions at one point after using it. In addition my lambda function is used.
I can definitely make and use it with a matching function, but it is fast disabling and error prone.
You can use "del", as told here
< P>and
Import the dill and set the variable 'recursive' to "true" value.
import dill dill.settings ['recurse'] = True
Let's say that f is your longitude function. You can dump it to disk using the following disk.
dill.dump (f, open ("myfile", "w"))
After this you can load the function from the following line . It can also be done with another dragon script.
f_new = dill.load (open ("myfile"))
No comments:
Post a Comment