Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44139
| Path | csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.066 |
| X-Spam-Evidence | '*H*': 0.87; '*S*': 0.00; 'output': 0.05; 'received :mail-vc0-f174.google.com': 0.09; '23,': 0.16; 'dictionary.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'likewise': 0.16; 'once.': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'input': 0.22; 'file.': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'received:209.85.220.174': 0.31; 'steven': 0.31; 'though.': 0.31; 'file': 0.32; 'run': 0.32; 'open': 0.33; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'received:google.com': 0.35; 'searching': 0.37; 'received:209': 0.37; 'skip:o 20': 0.38; 'depends': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; "you're": 0.61; 'close': 0.67; 'line,': 0.68; 'line*': 0.84; 'subject:skip:o 10': 0.84; '*for': 0.91; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=3QHMPu3TOhWVRBHirCVMdJE7KEbb6vu9Hko8wpK0Ftg=; b=DbW2v4KwchMBPYc+GMm2VTaD+Oq+Sgtf3+CdtDhWxSXs4hZQpfnzXWI3T16ROkdqOy HuFo0mf76BO7yBbGXdtrvLvmoSkd7Q0CXIT3xlblm732AqqpwOyeSGkC6ZF8c/rIA109 TBtFX1EiKiwWDCxGuL7NsrAuKDAIKJVSeQAT30xvOiGJEmU8PjQF/31oXoo9uW2hiNsn 3sahnfGxIIdouEFNVwYySGLuul1WfQhhoepbCBavjEhLd7V9549yDb2lX57o4MhWug3Y r2FCl+S4SE5VQDClFFP69hKTxsciDvQBk0PkB0kuFqusYCV2Eptsa8NskmlY/k4kw8g8 JGdQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.220.109.145 with SMTP id j17mr21016924vcp.34.1366690113352; Mon, 22 Apr 2013 21:08:33 -0700 (PDT) |
| In-Reply-To | <51760754$0$29872$c3e8da3$5496439d@news.astraweb.com> |
| References | <mailman.944.1366680414.3114.python-list@python.org> <51760754$0$29872$c3e8da3$5496439d@news.astraweb.com> |
| Date | Tue, 23 Apr 2013 14:08:33 +1000 |
| Subject | Re: optomizations |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.949.1366690116.3114.python-list@python.org> (permalink) |
| Lines | 16 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1366690116 news.xs4all.nl 2234 [2001:888:2000:d::a6]:57714 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:44139 |
Show key headers only | View raw
On Tue, Apr 23, 2013 at 2:00 PM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > Also, you're searching the file system *for every line* in the input > file. Pull this outside of the loop and have it run once: > > if not os.path.exists(outdir): > os.makedirs(outdir) > > Likewise for opening and closing the output file, which you currently > open and close it for every line. It only needs to be opened and closed > once. The outdir depends on the line, though. Hence my suggestion to retain the open files in a dictionary. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
optomizations Rodrick Brown <rodrick.brown@gmail.com> - 2013-04-22 21:19 -0400
Re: optomizations Roy Smith <roy@panix.com> - 2013-04-22 21:53 -0400
Re: optomizations Dan Stromberg <drsalists@gmail.com> - 2013-04-22 20:15 -0700
Re: optomizations Rodrick Brown <rodrick.brown@gmail.com> - 2013-04-23 00:20 -0400
Re: optomizations Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-23 04:38 +0000
Re: optomizations Chris Angelico <rosuav@gmail.com> - 2013-04-23 12:03 +1000
Re: optomizations Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-23 04:00 +0000
Re: optomizations Chris Angelico <rosuav@gmail.com> - 2013-04-23 14:08 +1000
percent faster than format()? (was: Re: optomizations) Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-04-23 09:46 +0200
Re: percent faster than format()? (was: Re: optomizations) Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-04-23 10:26 +0200
Re: percent faster than format()? Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-04-23 16:57 +0200
Re: percent faster than format()? Lele Gaifax <lele@metapensiero.it> - 2013-04-23 17:44 +0200
Re: percent faster than format()? (was: Re: optomizations) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-23 14:36 +0000
Re: percent faster than format()? (was: Re: optomizations) Chris Angelico <rosuav@gmail.com> - 2013-04-24 00:52 +1000
csiph-web