fastmath library?
Michael Hudson
mwh21 at cam.ac.uk
Fri Nov 17 08:49:48 EST 2000
"Alex Martelli" <aleaxit at yahoo.com> writes:
> "Michael Hudson" <mwh21 at cam.ac.uk> wrote in message
> news:m3zoizr5nx.fsf at atrus.jesus.cam.ac.uk...
> > "Pete Shinners" <pete at visionart.com> writes:
> >
> > > is there a "fast" math library available?
> > >
> > > 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
> > >
> > > i figure there's got to be something like this already
> > > available for python?
> >
> > Wouldn't have though there'd be much point - the faffing around Python
> > does in calling a function surely dwarfs the cost of the actual
>
> Indeed, *measuring* the proposed 'memoize' solution shows that:
[snip]
> I.e., the lookup-table is slowing things down
> by a factor of 4 or more (while the actual operation
> of math.sin accounts for just slightly more than
> 50% of the call-cost -- the comparison with the
> dummy-function call tells us that).
Hmm... you didn't post your dummy function! Anyway, I bet actually
computing the sin of the argument is still dwarfed by the function
call mechanism, so even if you have a fast C memoization/lookup thingy
then you aren't likely to save even 50% of the call cost. I could be
wrong, though (and am more likely to be on machines without an FPU).
Cheers,
M.
--
It's a measure of how much I love Python that I moved to VA, where
if things don't work out Guido will buy a plantation and put us to
work harvesting peanuts instead. -- Tim Peters, comp.lang.python
More information about the Python-list
mailing list