[Tutor] power of 2.718282

Adam Bark adam.jtm30 at gmail.com
Tue Jan 13 20:11:15 CET 2009


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(10)", "import math")
>>> t.repeat()
[0.42525100708007812, 0.43169903755187988, 0.4239799976348877]

>>> t=timeit.Timer("exp(10)", "from math import exp")
>>> t.repeat()
[0.36061406135559082, 0.36182284355163574, 0.35887718200683594]

2009/1/13 culpritNr1 <ig2ar-saf1 at yahoo.co.uk>

>
> 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.
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090113/02841438/attachment.htm>


More information about the Tutor mailing list