Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Pathlib.rglob can be orders of magnitudes slower thanglob.glob(recursive=True)
With a 1000-deep nested directory,glob.glob andPath.glob both took under 1 second.Path.rglob took close to 1.5 minutes.
importglobimportosfrompathlibimportPathx=""for_inrange(1000):x+="a/"os.mkdir(x)# ~ 0.5sprint(glob.glob("**/*",recursive=True))# ~ 87sprint(list(Path(".").rglob("**/*")))
Linked PRs
- GH-102613: Improve performance of
pathlib.Path.rglob()#104244 - GH-102613: Fix recursion error from
pathlib.Path.glob()#104373 - GH-102613: Fast recursive globbing in
pathlib.Path.glob()#104512 - gh-102613: Bump recursion limit to fix running test_pathlib under Coverage #105744
- [3.12] gh-102613: Bump recursion limit to fix running test_pathlib under Coverage (GH-105744) #105749