Python: spy for changes with sys.monitoring
SMRTR summary
Python 3.12 introduced sys.monitoring, a new framework for debugging and profiling tools. This feature allows developers to track specific events in their code with fine-grained control. The post demonstrates how to use sys.monitoring to detect changes in sys.path, the list that controls module import locations. By setting up a monitor function, developers can catch unexpected mutations and open a debugger when changes occur. This powerful tool can help pinpoint hard-to-find bugs, though its API is somewhat verbose.
SMRTR provides this summary for quick context. The original article belongs to Daily.dev.
Read the original article