Is Python reevaluating arithmetic operations with bignums each time the resut is used? -


okay, trying throw in large number evaluation on python - of order of 10^(10^120)- realized quite huge. anyways, receded 10**10**5 , 10**10**6. checking time difference of 2 brought me strange finding see inefficiency.

the finding when tried cprofile.run("x=10**10**6") took 0.3s , cprofile.run("print 10**10**6") took 40s.

then tried x= 10**10**6 took no time thereafter every time interpreted x (x followed enter) take long time (40s suppose). so, assuming every time interpret x calculates entire value on again.

so question is: isn't extremely inefficient? had declared variable in module, x= 10**10, , every time reference x python interpreter compute value of 10**10 on , on again ?

gory details appreciated.

the value not being recalculated each time print it, long delay see cost of converting large number string displaying.


Comments

Popular posts from this blog

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -