On Thu, Mar 19, 2009 at 2:54 AM, Christian Heimes <li...@cheimes.de> wrote: > Chris Rebert wrote: >> There's no effect on attribute read-writes as they all take place >> within the single __dict__ of the instance. As for method lookup, it >> doesn't add an indirection per se, but rather the list of classes to >> look thru to find a method gets longer, making base-class method >> lookups slower. IIRC, a typical method lookup does something like the >> following pseudocode: >> >> for klass in the_object.__mro__: >> if method_name in klass.__dict__: >> return klass.__dict__[method_name] >> raise AttributeError # no such attribute > > Your assumption is no longer true. Starting with Python 2.6 and 3.0 the > lookup of attributes is cached. You can find detailed information by > searching for VERSION_TAG in the source code.
Very interesting. Now that's a smart optimization; sounds a bit similar to what V8 does for JavaScript. Cheers, Chris -- I have a blog: http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list