[Python-3000] symbols?

Guido van Rossum guido at python.org
Thu Apr 13 09:54:15 CEST 2006


On 4/13/06, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Occasionally I wonder whether it would be useful
> to have some form of const declaration in the
> language, not to prevent accidental change, but
> so that access to them can be optimised. E.g. in
>
> const GET = 'GET'
>
> def f(address):
>    html_fungle(address, GET)
>
> the access to GET in the function could be
> compiled into some sort of array lookup instead
> of a global dict lookup.

But have you ever wondered if the microscopic speed-up would make
enough of a difference to bother with changing the language? (Not to
mention the problem of making the const-ness be preserved across
import -- in practice, the GET in this example would likely be
exported by the same module that exports  the function that uses it.
And, FWIW, that function is also likely a constant!)

> Although if a way is found to optimise global
> accesses in general, this might become unnecessary.

This will eventually happen one way or another, if only to shut up
complaints from people who believe it's a major cause of slowdowns.
:-)

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list