The sys.monitoring local events and code watcher APIs are pretty powerful for tracking execution granularly, but not global variable access. There are some libraries like mandala that have had to invent their own hacks for tracking global variable accesses, and it would be nice to have something more supported. Currently mandala copies function objects and replaces their __global__
dictionary with one that intercepts the lookups. But this is error prone because it requires users to manually decorate every function that could access a global. Ideally you would be able to register for a callback that would give you the module and qualname for the global (this way in later runs you can lookup the global to see its current value vs what you recorded in the past).