[Tutor] power of 2.718282

Marc Tompkins marc.tompkins at gmail.com
Tue Jan 13 23:09:18 CET 2009


On Tue, Jan 13, 2009 at 1:39 PM, Alan Gauld <alan.gauld at btinternet.com>wrote:

> I would appreciate a low level solution because I have to iteratively call
>> that computation millions of times. Anything more efficient than
>> 2.718182**10 may be good.
>>
>
> Umm, what's wrong with
>
> from math import e  # more precision than 2.718182
> print e**10
>

Apparently nothing at all is wrong with it:
C:\Python25\Lib>python timeit.py -s "import math" "x=math.exp(10)"
1000000 loops, best of 3: 0.678 usec per loop

C:\Python25\Lib>python timeit.py -s "from math import e" "x=e**10"
1000000 loops, best of 3: 0.411 usec per loop



-- 
www.fsrtechnologies.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090113/3c08a1fd/attachment.htm>


More information about the Tutor mailing list