Guido van Rossum wrote: > - The required global analysis is a bit hairy, and not something we > already do. I believe that Jeremy thinks PyChecker already does > this; I'm not sure if that means we can borrow code or just ideas. The algorithm pychecker uses is pretty simple. I think something like this should work: for each method: self = method.co_varnames[0] for each byte code in method: if op == STORE_FAST and oparg == self: break # we don't know self anymore if (op == STORE_ATTR or op == LOAD_ATTR) and selfOnTop: # we have an attribute store it off selfOnTop = (LOAD_FAST and oparg == self) Note that storing the attributes could be done during the compilation step. This means that it should be simple housekeeping in the compiler to store the info and not require another pass (as in pychecker). Neal
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4