nth root

Mark Dickinson dickinsm at gmail.com
Sat Jan 31 09:03:07 EST 2009


On Jan 31, 1:23 pm, Steve Holden <st... at holdenweb.com> wrote:
> [Mark]
> > power operation.  The integer -> float conversion is probably quite
> > significant, timewise.
>
> I bow to your superior intuition!

Here's another timing that shows the significance of the int -> float
conversion: (non-debug build of the trunk)

>>> t1 = timeit.Timer("x = n**power", "n = 4021503534212915433093809093996098953996019232; power = 1./13")
>>> t2 = timeit.Timer("x = n**power", "n = 4021503534212915433093809093996098953996019232.; power = 1./13")
>>> t1.timeit()
0.34778499603271484
>>> t2.timeit()
0.26025009155273438

I've got a patch posted to the tracker somewhere that improves
the accuracy of long->float conversions, while also speeding them
up a tiny bit (but not a lot...).

Mark



More information about the Python-list mailing list