Earlier quoted context omitted.
There are plenty of things for which python is not slow, but people using python don't know a lot about programming, and end up with a slow result. A couple of advises: - the right algo will go a long, long way. - know your data structures. E.G: assigning to a slice is ridiculously fast (even while unpacking), memory views may save a lot on byte heavy workloads, heapq and deque are underrated, etc. Also check out htt…
>pathlib and dataclasses. In a regular code they are great. On a bottleneck however, they are very slow. Do you have any numbers to back this up? Why would Pathlib be slow?
TL;DR: Path() initialization is very heavy compared to simple strings, and subsequent path operations produce new Path() objects every time.
The video then illustrates the point with a patch to the black formatter cache yielding a 40X speedup.