dunder-docs (was Python is DOOMED! Again!)
Marko Rauhamaa
marko at pacujo.net
Tue Feb 3 18:32:14 EST 2015
Gregory Ewing <greg.ewing at canterbury.ac.nz>:
> 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.
No, I'm saying Python should behave differently.
Python:
>>> class A:
... def f(self):
... print("f")
... def g(self):
... print("g")
...
>>> a = A()
>>> a.__class__.f = a.__class__.g
>>> a.f()
g
In my preferred semantics, a.f() would print
>>> a.f()
f
Marko
More information about the Python-list
mailing list