i need to divide a number which is a long duration in seconds by the number of seconds in a week (604800) to get the number of weeks. if i were to write the code as an expression of literal constants like
the choice of seconds in a week is just one use case. for this division i may be using
7*24*60*60
, would CPython compile this as 604800
so only the divide is done at run time? does it always compile and reduce constant expressions as if given as a literal?the choice of seconds in a week is just one use case. for this division i may be using
divmod()
. the purpose of writing the code this way is to show the components of the numbers which many people will not immediately recognize (if ever). IMHO, more people will understand w=delta/(7*24*60*60)
than w=delta/604800
. but if i do that deep in a busy loop ...
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.