Python 3.9 StatsProfile — My first OSS Contribution to cPython
You can try out all of the code in this article yourself using this Google Colaboratory notebook. If you’ve ever tried to debug and optimize your python application, it’s likely that you stumbled upon Python Profiles to understand where most of the execution time is being spent. You enable the profiler at the beginning of a code segment you’re interested in profiling with pr.enable(), and call pr.create_stats() at the end. Afterwards, you can create a Stats object, and print the results in a human readable format with ps.print_stats(). ...