42**1000000 is CPU time free

candide c.candide at laposte.net
Fri Jul 24 22:54:54 CEST 2015


Of course, computing 42**1000000 is not free:


# ------------------
import time

a=time.clock()

N=1000000
42**N

b=time.clock()

print("CPU TIME :", b - a)
# ------------------


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CPU TIME : 2.37

real    0m2.412s
user    0m2.388s
sys     0m0.016s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So please, explain the following:


# ------------------
import time

a=time.clock()

42**1000000

b=time.clock()

print("CPU TIME :", b - a)
# ------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CPU TIME : 0.0

real    0m2.410s
user    0m2.400s
sys     0m0.008s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(focus on the CPU TIME!!)


More information about the Python-list mailing list