[issue39907] `pathlib.Path.iterdir()` wastes memory by using `os.listdir()` rather than `os.scandir()`

Barney Gale report at bugs.python.org
Mon Mar 9 10:56:02 EDT 2020


Barney Gale <barney.gale at gmail.com> added the comment:

Less reliable how? Doesn't appear any slower:

barney.gale at heilbron:~$ python3 -m timeit -s "import os; os.listdir('/usr/local')"
100000000 loops, best of 3: 0.0108 usec per loop
barney.gale at heilbron:~$ python3 -m timeit -s "import os; list(os.scandir('/usr/local'))"
100000000 loops, best of 3: 0.00919 usec per loop

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39907>
_______________________________________


More information about the Python-bugs-list mailing list