python reduce constants at run or compile?

Pete Shinners pete at
Thu Sep 7 03:03:58 CEST 2000

if i have the following sample code...


does the "120-44" get computed to 76 at compile time, or is
the value computed at runtime?

next, i ask a step further. since tuples are immutable
(as close to '"C" constant' as i can get?) is the python
interpreter clever enough to reduce this one for me?

DATARANGE = (44,120)

am i correct in believing that even if python doesn't
reduce this down at compile time, it 'potentially could'?
(doublechecking my understanding of tuples)

if the compiler isn't taking care of these, should it?
what are the major complexities keeping it from this?
(i'll likely understand, but have tiny knowledge of
python specific internals)

thanks, just trying to help my coding by knowing what's
going on behind the scenes.

More information about the Python-list mailing list