Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Tim Chase Newsgroups: comp.lang.python Subject: Re: How to get a directory list sorted by date? Date: Sun, 15 May 2016 13:12:32 -0500 Lines: 24 Message-ID: References: <20160515061511.7c62b0e1@bigbox.christie.dr> <20160515131232.200268cf@bigbox.christie.dr> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de vbkoZImuy4yYu6NIJQcQ3wjhMfA0aLq6d77zRpxpFgJQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'calls.': 0.07; 'feature.': 0.07; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; 'filenames,': 0.09; 'highlighting': 0.09; 'inclusion': 0.09; 'typed': 0.09; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'hypothetical': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sorted()': 0.16; 'wrote:': 0.16; 'memory': 0.17; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'algorithm': 0.20; 'cc:no real name:2**0': 0.22; 'thanks,': 0.24; 'tim': 0.24; 'header:In-Reply- To:1': 0.24; 'subject:list': 0.26; 'sequence': 0.27; 'initial': 0.28; 'chase': 0.29; 'reduced': 0.29; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'agree': 0.37; 'charset :us-ascii': 0.37; 'entire': 0.61; 'provide': 0.61; 'details': 0.62; 'results': 0.66; 'reply': 0.68; 'subject:get': 0.81; 'one).': 0.84; 'peter,': 0.84; 'received:23': 0.84; 'edwards': 0.91 X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|tim@thechases.com X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1463335954234:230733810 X-MC-Ingress-Time: 1463335954234 In-Reply-To: X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) X-AuthUser: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20160515131232.200268cf@bigbox.christie.dr> X-Mailman-Original-References: <20160515061511.7c62b0e1@bigbox.christie.dr> Xref: csiph.com comp.lang.python:108643 On 2016-05-15 14:36, Grant Edwards wrote: > On 2016-05-15, Tim Chase wrote: > > unless sorted() returns a lazy sorter, > > What's a lazy sorter? A hypothetical algorithm that can spool out a sorted sequence without holding the entire sequence in memory at the same time. Though I typed that initial reply a little quickly, as I hadn't known at the time that scandir()'s results also provide stat() results with reduced overhead (whereas listdir() just returns the filenames, so you have to stat() each one). Thanks, Peter, for highlighting this feature. So in light of my newfound knowledge, I humbly retract my snark and agree that it's better to exploit scandir()'s inclusion of stat() details without additional calls. -tkc