On Tue, Jan 13, 2009 at 5:09 PM, Marc Tompkins wrote:
> Apparently nothing at all is wrong with it:
> C:\Python25\Lib>python timeit.py -s "import math" "x=math.exp(10)"
> 100 loops, best of 3: 0.678 usec per loop
>
> C:\Python25\Lib>python timeit.py -s "from math import e" "x=e**10"
> 100
On Tue, Jan 13, 2009 at 1:39 PM, Alan Gauld 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 th
"culpritNr1" 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
e**10 is shorter
According to a quick interactive session and the timeit module it's quicker
to do 2.71828**10 than using math.exp, I'm guessing cos of the function
call.
>>> t=timeit.Timer("2.718282**10")
>>> t.repeat()
[0.073765993118286133, 0.066617012023925781, 0.06807398796081543]
>>> t=timeit.Timer("math.exp
Thanks Marc and Kent and all. math.exp() is what I was looking for.
culpritNr1
--
View this message in context:
http://www.nabble.com/power-of-2.718282-tp21441385p21441787.html
Sent from the Python - tutor mailing list archive at Nabble.com.
___
Tu
On Tue, Jan 13, 2009 at 1:19 PM, culpritNr1 wrote:
>
> Hello All,
>
> It such a simple question, but because of that, googling for an answer just
> pulls the wrong results.
>
> How do I compute a power of e in Python?
>
> Say I need 2.718282 to the 10th. In R for example, I just do exp(10).
impor
On Tue, Jan 13, 2009 at 10:19 AM, culpritNr1 wrote:
>
> How do I compute a power of e in Python?
>
> Say I need 2.718282 to the 10th. In R for example, I just do exp(10).
>
> I would appreciate a low level solution because I have to iteratively call
> that computation millions of times. Anything m
Hello All,
It such a simple question, but because of that, googling for an answer just
pulls the wrong results.
How do I compute a power of e in Python?
Say I need 2.718282 to the 10th. In R for example, I just do exp(10).
I would appreciate a low level solution because I have to iteratively c