Function call dependency tracking in Python / how to do it in Julia

I found this post from a Python friend of mine very interesting, especially in the context of comparing Python and Julia introspection and metaprogramming tools. He works through what is necessary for function-level dependency tracking in python code – a really impressive level of metaprogramming. Maybe even Julia uses too much dark magic to implement similar capabilities (IRTools, Cassette, etc). I am curious whether folks have quick and rough pointers on what to learn in order to implement the same capabilities in Julia. I would like to stress that it took just about 100 lines to do a first version in python.

It was rather difficult for me to find a good place to post this, but paradoxically “Internals” seems like the best category, given the amount of introspection being discussed.

Direct link: Practical dependency tracking for Python function calls | Alex Makelov

looks like you need to modify the source code to do that? idk, try to call numpy function, see if it can work across boundary.

On the Julia side I’m sure JET.jl does this already, but matter of visualization I guess

1 Like

Cthulhu and JET do this based on the statically reachable call-graph, and indeed it would only be a matter of extracting the information and visualizing it.

If you want the full dynamic call-graph you would need to use Cassette, in particular the pre/post call hooks were meant to do tracing like that.