dunder-docs (was Python is DOOMED! Again!)
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Feb 3 21:30:17 EST 2015
Gregory Ewing wrote:
> Marko Rauhamaa wrote:
>> Right now Python generates the trampoline from the class prototype every
>> time you call a method. If the semantics allowed, you could create the
>> trampoline at instantiation time (for better or worse). That way, the
>> problem you seem to be referring to wouldn't materialize.
>
> Sorry, I misinterpreted what you were suggesting.
>
> You seem to be suggesting an optimisation that pre-creates
> bound methods when the instance is created. Keeping a
> cache of bound methods would achieve the same thing
> without changing the semantics. I think CPython
> might already be doing that, but I'm not sure.
It's not.
py> class K(object):
... def f(self): pass
...
py> k = K()
py> k.f is k.f
False
--
Steve
More information about the Python-list
mailing list