question about the id()
Dan Sommers
me at privacy.net
Tue May 17 19:14:33 EDT 2005
On Tue, 17 May 2005 13:56:18 +0200,
Peter Dembinski <pdemb at gazeta.pl> wrote:
> "Giovanni Bajo" <noway at sorry.com> 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/>
More information about the Python-list
mailing list