[Python-ideas] Specifying constants for functions

Serhiy Storchaka storchaka at gmail.com
Tue Oct 27 14:36:16 EDT 2015


On 27.10.15 19:55, Yury Selivanov wrote:
> I see this a lot in all kinds of code.  In my experience it doesn't
> actually speed things up in a measurable way.
>
> I think that adding a "const" statement deserves some discussion, but
> not from the standpoint of micro-optimizations.

Agree, we slowly gots rid of such microoptimizations. Seems that 
builtins and globals lookup is much faster in current CPython than was 
when such microoptimizations were added.

Yet one application of this trick is binding globals and module's 
members in __del__ methods and functions that can be called at shutdown 
time after module's content cleared. But this is very limited application.



More information about the Python-ideas mailing list