Tim Chase <python.l...@tim.thechases.com> writes: > The difference in timings when serving a web-request are noticeable > (in my use-case, I had to change my algorithm and storage structure to > simplify/avoid heavily-populated directories)
So, if the requirement is “test whether the directory is empty faster than N microseconds”, that's quite different from “without the generation of a list of the file names”. The former may entail the latter, but that's not to be assumed, and chasing an optimisation prematurely is a common cause of terrible code. Therefore, I'm asking the OP what is their (so far unstated) reason for caring about the implementation of a standard library call. Without that, it would be folly to try to suggest a solution. With that, it may turn out the stated requirement isn't relevant for satisfying the actual requirement. I don't know (and it's possible the OP doesn't know) the relevance of the “create a list of entries” part, so I asked. -- \ “Science is a way of trying not to fool yourself. The first | `\ principle is that you must not fool yourself, and you are the | _o__) easiest person to fool.” —Richard P. Feynman, 1964 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list