On Tue, 17 May 2005 13:56:18 +0200,
Peter Dembinski <[EMAIL PROTECTED]> wrote:

> "Giovanni Bajo" <[EMAIL PROTECTED]> writes:
>> Peter Dembinski wrote:
>> 
>>>> BTW, a typical performance optimization (not done automatically by
>>>> python) is to hoist unchanging-value expressions out of loops, and
>>>> obj.method is often such an expression, so you will this strategy
>>>> when people try
>>>> to squeeze extra performance from their programs.
>>> 
>>> Good to know.  Is there any advanced optimizer for Python code,
>>> which would do such things for me (or suggest them, like pychecker
>>> does for readability)?
>> 
>> 
>> Prove that a.f() would not change the meaning of "a.f" after its
>> invokation is close to impossible.

> Many things in Python programs cannot be proved.  But what about
> suggesting optimisations, not doing them automatically?  

At that point, you can do the optimization yourself:

    class A:
        def method( self ):
            pass

    a = A( )
    m = a.method # optimize runtime lookups for a.method
    for x in range( 10 ):
        m( )

Regards,
Dan

-- 
Dan Sommers
<http://www.tombstonezero.net/dan/>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to