Smalltalk-style "senders" and "implementors"

brooklineTom at gmail_spam_blocking_suffix.com brooklineTom at gmail_spam_blocking_suffix.com
Mon Mar 31 15:57:44 CEST 2008


I'm wondering if anyone has coded up a way to do Smalltalk-style
runtime "senders" and "implementors" for python methods.

For senders, I think the idea is to traverse the module space and
collect, for each method, the names of any methods or functions it
calls. In Smalltalk, the workhorse is "CompiledMethod>>sendsSelector".
The Smalltalk heuristic is to collect a method name, then traverse all
the classes, and within each class traverse all the CompiledMethod
instances, invoking the above and collecting the results.  I'm
wondering if an equivalent exists for Python.

For implementors, the idea is to traverse the module space looking for
classes that define some supplied method name.

I'm looking for a way to do this, at run-time, based on the modules
that are actually loaded (rather than a full-text traversal of all the
files).

The purpose is so that I have a way to make refactoring easier. For
example, when I need to change a method name, I want an easy way to
find all the methods that invoke it. Full-text lexical search works,
but answers lots of false hits, for example from packages where unused
files are still hanging around.

Thx,
Tom



More information about the Python-list mailing list