Rémi Lapeyre <[email protected]> added the comment:
This is not how timeit works, you just measured the time taken by an empty
loop, you can look at `python3 -m timeit -h` to get help how to call it. I
think a correct invocation would be:
(venv) ➜ ~ python3 -m timeit -s 'from os import scandir'
"list(scandir('/usr/local'))"
10000 loops, best of 5: 24.3 usec per loop
(venv) ➜ ~ python3 -m timeit -s 'from os import listdir'
"listdir('/usr/local')"
10000 loops, best of 5: 22.2 usec per loop
so it looks like scandir as a small overhead when accumulating all results and
not using the extra info it returns.
----------
nosy: +remi.lapeyre
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue39907>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com