[pypy-dev] A problem with unbound methods

Armin Rigo arigo at tunes.org
Wed Apr 12 15:37:01 CEST 2006


Hi Antonio,

On Thu, Apr 06, 2006 at 09:31:04PM +0200, Antonio Cuni wrote:
> Ok, now it's clearer, thanks. So, to respond to my original question, I 
> should create a sort of "graph database" to lookup when I need to know 
> where have I put the code for that graph, right?

We could try to do this in a way that is reusable between multiple
back-ends, because many OO back-ends will have a similar problem.  What
needs to be done is to collect all graphs and see how they are used.
For each graph, it means: which regular method(s) are implemented with
that graph, and which direct_calls are done to staticmethods implemented
with that graph.

Then we need some cases.  We can be more sutble, but as a minimum we
need logic like: if a graph is used only as one method, leave it alone.
If it is used only as a static method, leave it alone too (and declare
it as a static method somewhere).  For more complicated cases, find all
methods implemented with this graph, and replace each of them with a new
stub graph that just contains a direct_call to the original graph as a
static method.

Such a transformation would "normalize" the methods in the OOClass
objects (so that the approach you're currently using in CLI would
continue to work for methods) and also generate a list of remaining
graphs that the back-end needs to declare as static methods.


A bientot,

Armin.



More information about the Pypy-dev mailing list