Hi Erik, 2007/8/22, Erik Gorset <[EMAIL PROTECTED]>: > On Aug 22, 2007, at 7:56 AM, David Cournapeau wrote: > > For example, the following python code: > > > > class A: > > def _foo(self): > > return None > > def foo(self): > > return self._foo() > >
[snip] > More specific for your example, it will result in code looking > something like this: > > class A_compiled: > def foo(self): > if type(self) == A: > return None # _foo has been inlined > else: > return self._foo() # uncommon case > > Of course, the higher up you can start inlining, the less calls is > needed and > better performance is achieved: > > a = obj.foo() > > turns into: > > if type(obj) == A: > a = None > else: > a = obj.foo() those inline checks are not enough in the Python case. You also need to check that the method A.foo was not changed in the meantime. But yes, in principle this is the idea. It works even better in the case of integer-handling functions, because the inlined operations can in many cases be implemented by processor opcodes. Cheers, Carl Friedrich _______________________________________________ [email protected] http://codespeak.net/mailman/listinfo/pypy-dev
