Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75840 > unrolled thread
| Started by | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| First post | 2014-08-07 06:07 -0500 |
| Last post | 2014-08-07 06:07 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Test for an empty directory that could be very large if it is not empty? Tim Chase <python.list@tim.thechases.com> - 2014-08-07 06:07 -0500
| From | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| Date | 2014-08-07 06:07 -0500 |
| Subject | Re: Test for an empty directory that could be very large if it is not empty? |
| Message-ID | <mailman.12723.1407409742.18130.python-list@python.org> |
On 2014-08-07 11:27, Ben Finney wrote: > > 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. I guess my surprise in the 2->3 non-iterator'ization of os.listdir() is that it's very easy to wrap an iterable in list() if you want the whole bunch, but it's much harder to get the performance characteristics of interruptible iteration (e.g. "is the directory empty" or "look at files until you find one matching $CRITERIA"). Looking forward to scandir() arriving for just those reasons. -tkc (who sees Ethan Furman's excellent followup-post as I'm about to hit Send)
Back to top | Article view | comp.lang.python
csiph-web