Using Python Context Manager for Profiling
24/08/2017
by Abhijit Gadgil
Profiling your code to identify hotspots or potential performance issues can prove quite useful. Python provides a cProfile
package in the standard library provides this functionality for deterministic profiling. Usually, one might want to have an ability to turn profiling on and off at the run-time if possible. We explore a mechanism based on context managers in Python (Python with
syntax) to be able to do so.