How to profile slow code in Python

preview_player
Показать описание
In this video we look at an interesting use case we stumbled upon the other day, a Bite submission that timed out.

We first look at which of the functions is slow using a timer decorator.

When we pinpointed the slow function we look at where exactly in this function the most time is spent / calls are made.

It becomes soon apparent that it's an expensive operation in a for loop.

Hopefully this video helps you whenever you are hit with slow code.

Used decorators are here:

Also check out mentioned useful profiling context manager here:

----------------------------
----------------------------

There's plenty more to discover with PyBites:

Рекомендации по теме
visit shbcf.ru