Fredrik Lundh wrote:

>> But in most cases the 'constant' is actually an expression involving a
>> global, often even a global in another module. (E.g. sre_compile.py)
>> The compiler will have a hard time proving that this is really a
>> constant, so it won't optimize the code.
> 
> unless we come up with a way to make it possible to mark an variable as 
> a constant.

such as the primary

     'constant' expr

which simply means that expr will be evaluated at function definition 
time, rather than at runtime.  example usage:

     var = expression
     if var == constant sre.FOO:
         ...
     elif var == constant sre.BAR:
         ...
     elif var in constant (sre.FIE, sre.FUM):
         ...

</F>

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to