How do I check if a python function changed (in live code)? -
if have reference function can check it's code object f.__code__, signature, perform later checks against signature see if code changed. good. if 1 of funciton's dependencies changed? e.g.
def foo(a, b): return bar(a, b) let's foo remained same, bar changed. there way can check foo's dependencies 'live' via foo.__code__ object (vs. parsing text , using ast)?
i'm poking around @ __code__ object here, can't work sure, looks me use co_names tuple (recursively) traverse call graph rooted @ particular function, in order build sort of hash of transitive closure of functions possible called. (i don't think it'd possible include functions will called particular input, conservative , include every possible call.)
to you'd need maintain sort of symbol table able names of functions called. once start going down path, seems you're going build own equivalent of ast. so, why not use ast start ?
Comments
Post a Comment