Jeff Clites <[EMAIL PROTECTED]> wrote:
> 2) I'd expect the method cache to be per-class, but Python can change
> an attribute slot on a per-instance basis (as well as a per-class
> basis), so we can't really use a per-class method cache (or, we need a
> flag on particular instances which tell us not to use it for them).
The method cache is per class. But we have properties too. Per-instance
attributes end up as properties. If there is a flag or method cache
invalidation is a matter of taste and depends on method resolution
order.
> 3) I won't mention the problem of languages which allow an object to
> have instance variables and instance methods of the same name (so that
> in Python, "a.b" would be ambiguous if "a" is an object from such a
> language).
Well, Python has that very problem. By dynamically defining an instance
variable, a method with that same name becomes inaccessible.
>>> class A(object):
... def b(self):
... print "b"
...
>>> a=A()
>>> a.b()
b
>>> a.b=2
>>> a.b()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'int' object is not callable
> JEff
leo