constant in python?

Michael Ströder michael at stroeder.com
Sat Aug 18 13:36:53 CEST 2001


Alex Martelli wrote:
> 
> > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65207
> 
> If something can be done with a few lines of code in the
> language as it is, it requires very strong motivation for that
> something to become a built-in language mechanism:

I would guess that the recipe above causes some performance penalty.

> I think that "constants" are a good
> example of something that should NOT be in the language
> itself, exactly because it's a minor issue and it can be
> easily implemented without too much trouble

Disclaimer: I'm not a compiler expert.
IMHO constants are useful in compiled languages because they are
immutable and therefore a compiler can insert them as "in-line"
operands for optimization.

Ciao, Michael.



More information about the Python-list mailing list