How do you make your Python code faster? The first step is measuring what part is actually slow. We do this using a profiler, such a cProfile. The profiler measures how much time all your function calls take and then you can print or save these statistics to determine where you should spend your time improving. Take your profiling to the next level using a graphical tool like snakeviz to analyze the stats.

I go through a simple example where I go from start to finish diagnosing and fixing some slow code using these techniques. Here we ended up using async/await to fix the problem, but the tools in this video can be used to diagnose all sorts of code problems.

Source code: https://github.com/mCodingLLC/VideosS…

cProfile docs: https://docs.python.org/3/library/pro…

snakeviz: https://jiffyclub.github.io/snakeviz/

httpx: https://www.python-httpx.org/

Subscribe: https://www.youtube.com/c/mCodingWithJamesMurphy/featured

#python

Find Why Your Python Code is Slow Using this Essential Tool. (Feat. async/await)
13.80 GEEK