![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Facundo Batista <facundo@taniquetil.com.ar> added the comment: However, Serhiy, `os.listdir()` builds a list quickly and gives you that, so the chance of the directory being modified is quite low (however, for big directories, that may happen, and it's probably good to notice that in the docs). For `Path.iterdir()` that list is not built, and as it's iteration is external, the amount of time between getting one item to the other is unbound, *anything* could happen in the middle. In short, I think that both docs should state that the directory could change while it's iterated (in the os.listdir case probably stating that the chances are low). ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40486> _______________________________________