开发者

storing computed function to disk for fast access in python

There are two parts to my question. One: I have to do a double integration on a grid

answer = integrate (  f(x,y) times besselfunction(x,y))

Now, I have read that the besselfunction can be precomputed and saved to disk for fast access. How do I do this? Right now, I am evaluating the besselfunctio开发者_如何学运维n from scipy.special as it is required.

Second question: I have numerically integrated a differential equation and I use the splined solution to solve other differential equations. However the splined solution is slow. Is there a way to make this faster?


You seem to be looking for an on-disk memoization solution.
You could probably make a memoization decorator that uses berkeleydb to store the results of all function calls computed so far onto disk (if you can carry the resulting berkeleydb file around to every machine you run your program on and don't mind it becoming really huge, you would need to compute the function for a given set of args only once ... I don't know if this is such a good idea in context of what you are doing here though)
Googling for "memoize decorator disk" seems to bring up some interesting solutions to your problem.
This one in particular looks kinda promising - http://www.stanford.edu/~pgbovine/incpy.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜