New statement proposal for Python

Greg Ewing see at my.signature
Tue Jun 19 01:39:21 EDT 2001


Tim Peters wrote:
> 
> Almost all Python code "spells a constant" via
> 
>     UPPERCASE_NAME = some_expression
> 
> and in 10+ years of Python practice I've never rebound such a name by
> accident -- or heard of anyone else doing so either.

I second that. However, I think there's another issue
related to this: sometimes I'm discouraged from using
named values like this because of the relative
inefficiency of looking up globals as opposed to
locals.

Having a "const" syntax would be one way of addressing
this, since the compiler would have opportunities to
optimise.

Instead of introducing a new syntax, however, I'd rather
see some work done on the implementation of module
namespaces to make them more like local namespaces
are now -- i.e. so that names the compiler knows about 
are accessed by indexing into an array instead of
looking up a dictionary.

I think this would be a much more worthwhile investment
of effort, since it would benefit *all* accesses to
globals, not just "constant" ones!

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list