Request for review of "GH-116380: Speed up glob.glob() by removing some system calls"

This PR makes glob.glob() and glob.iglob() use several performance tricks developed in pathlib. In fact it unifies the implementations of globbing across the two modules! The speedup depends on many factors including the pattern itself, but on my machine I see at least a 1.5x improvement for the majority of test cases I try.

I’ve already laid some groundwork with private glob._GlobberBase and _StringGlobber classes, which power pathlib’s globbing. The PR adds support for dir_fd and include_hidden in those classes, and makes glob() and iglob() use them.

I’d be grateful for reviews. Here’s the PR:

Thanks all!

5 Likes