On 4/13/06, Greg Ewing <[EMAIL PROTECTED]> 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/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com