Message242065
Timing results on my machine:
(Canopy 64bit) taniyama:~ mdickinson$ python3 -m timeit -s "from math import sqrt; x = 3.14" "sqrt(x)"
10000000 loops, best of 3: 0.0426 usec per loop
(Canopy 64bit) taniyama:~ mdickinson$ python3 -m timeit -s "from math import sqrt; x = 3.14" "x**0.5"
10000000 loops, best of 3: 0.0673 usec per loop
And the disassembly showing the peephole optimizer at work:
>>> def f(): return 3.14**0.5
...
>>> import dis
>>> dis.dis(f)
1 0 LOAD_CONST 3 (1.772004514666935)
3 RETURN_VALUE |
|
Date |
User |
Action |
Args |
2015-04-26 17:29:49 | mark.dickinson | set | recipients:
+ mark.dickinson, tim.peters, rhettinger, serhiy.storchaka |
2015-04-26 17:29:49 | mark.dickinson | set | messageid: <1430069389.87.0.288237546506.issue24059@psf.upfronthosting.co.za> |
2015-04-26 17:29:49 | mark.dickinson | link | issue24059 messages |
2015-04-26 17:29:49 | mark.dickinson | create | |
|