We currently perform a full scan of the method table when you first access a class to ensure that the dir() function works. That slows down initialization, and uses more memory than needed.
What's worse is that we basicly do a rescan on every method calls, and that is way to expensive (the rescan is needed because the runtime doesn't have a callback API for changes).
All of this can be done lazily with Python 2.6 or later:
Implement dir, perform a full scan there to ensure that
Do not perform a full scan when loading the class, or when calling
In getattribute: cache that a method was found, probably even
when the method is found in a superclass (to avoid slowdown when calling methods defined in a superclass)
This means we can no longer add special methods by looking
for selectors after doing the full scan (e.g. add getitem when @Aleksey Marchak(valueForKey:) is defined), switch to explicitly adding special methods to particular classes instead.