3 ms·
>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 Pa
by dralley 5y ago
>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?
- BiteCode_dev 5y agoAnthony Sottile has a good bit on it: https://www.youtube.com/watch?v=tFrh9hKMS6Y https://www.youtube.com/watch?v=tFrh9hKMS6Y 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.
- dralley 5y agoOh, that is unfortunate. Thanks for the tip.