Chris Rebert a écrit :
On Wed, Mar 18, 2009 at 6:09 AM, Anthra Norell <anthra.nor...@bluewin.ch> wrote:
Would anyone who knows the inner workings volunteer to clarify whether or
not every additional derivation of a class hierarchy adds an indirection to
the base class's method calls and attribute read-writes. In C++, I suppose,
a three-level inheritance would resolve into something like
*(*(*(*(base_class_method ())))).
There's no effect on attribute read-writes as they all take place
within the single __dict__ of the instance.
Except when:
- the attribute is a computed one (property or other descriptor)
- (for read access) the attribute is not set in the instance's dict.
As for method lookup, it
doesn't
make much difference - the very same lookup rules apply, and it's the
descriptor protocol (as implemented by the 'function' type) that takes
care of returning a method object (mostly a partial application of the
function to the instance or class) when appropriate.
(snip)
However, you shouldn't really worry about the inefficiency of a deep
inheritance tree as Python
is probably not the right tool for the job if one have such efficiency
concerns.
(snip)
[Note: I'm purposefully ignoring the fact that methods and attributes
are in reality looked up in the exact same way for
simplicity/clarity.]
Ah, ok - then please don't take the above remarks as a personal offense !-)
(still posting this since it might be of interest to the OP or someone
else).
--
http://mail.python.org/mailman/listinfo/python-list