The speed of glob()

Chris Angelico rosuav at gmail.com
Wed Jul 29 04:56:23 EDT 2020


On Wed, Jul 29, 2020 at 6:27 PM Gisle Vanem <gisle.vanem at gmail.com> wrote:
>
> Has anybody noticed the speed of 'glob()' has
> decreased somewhere between v3.6 and v3.10.
>
> I got these results:
>    Python 3.6.5:
>      1st run: 0.14694
>      2nd run: 0.09506   <- *always* the fastest
>    Python 3.7.7:        <- from Nuget
>      1st run: 0.12440
>      2nd run: 0.09602
>    Python 3.10.0:       <- from Git repo
>      1st run: 0.15922
>      2nd run: 0.12424
>
> 'glob()' in Python 3.6.5 is consistently 30% faster on
> the 2nd run compared to 3.10.0.
>

Unfortunately that's very hard to compare. If you're building Python
from source, the parameters may be VERY different from a prepackaged
binary.

Are you able to redo this test with more consistent Python builds? For
instance, you can go as far as 3.8 using python.org binaries, or
alternatively, build all your tests from git (by checking out
different branches).

My guess is that something changed in the caching rules when
listdir/scandir changes happened, but there's no way to know for sure.

ChrisA


More information about the Python-list mailing list