News for hackers. Stuff that matters.
Re:You Should Compile Your Python and Here’s Why by dralley on Friday April 29, 2022 @02:14PM (#31208791)
>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?

Re:You Should Compile Your Python and Here’s Why by BiteCode_dev on Friday April 29, 2022 @02:24PM (#31208919)
Anthony Sottile has a good bit on it: 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.

Re:You Should Compile Your Python and Here’s Why by dralley on Friday April 29, 2022 @02:26PM (#31208943)
Oh, that is unfortunate. Thanks for the tip.