fastmath library?
William Park
parkw at better.net
Thu Nov 16 17:42:29 EST 2000
On Thu, Nov 16, 2000 at 03:18:33PM -0600, William Annis wrote:
> "Pete Shinners" <pete at visionart.com> writes:
>
> > one that uses high-speed lookup tables and estimates for
> > low quality results? i'd mainly like one that can handle
> > things like square-root, cosine, etc, etc
>
> This lookup-don't-compute behavior is sometimes called
> memoizing.
>
> > i figure there's got to be something like this already
> > available for python?
>
> Well I've written the little memoizing class below. I'm not
> sure the overhead will help you in the case of sine and cosines, but
> certainly will for more complex functions:
<cut>...</cut>
> Basically, it keeps a dictionary of arguments. When it has
> seen the arguments before, it just looks up the data. When they're
> new, it does the computation. So, this is only helpful when you're
> calling the memoized function a lot.
I would think that the class attribute lookup would be slower than
calling C math function. This would defeat the original question for
speed.
For speed, write the table lookup or approximation in C.
---William Park, Open Geometry Consulting
More information about the Python-list
mailing list