Class proxy should be more lazy
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
introspection works
Do not perform a full scan when loading the class, or when calling
a method
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.
Comments (5)
-
-
- changed component to pyobjc-core
- changed version to 3.0
-
I have a (local) 3.0 branch where I've implemented this. The code still needs some cleanup, but basicly works.
-
- changed status to resolved
This is implemented in the 3.0 branch.
-
- removed version
Removing version: 3.0 (automated comment)
- Log in to comment
Issue
#12was marked as a duplicate of this issue.