Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63911
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python.list@tim.thechases.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.015 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.06; 'f.close()': 0.09; 'noted,': 0.09; "'w')": 0.16; '-tkc': 0.16; 'dump': 0.16; 'file-like': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'iterable': 0.16; 'wrote:': 0.18; 'handles': 0.22; 'file.': 0.24; 'this:': 0.26; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'fastest': 0.30; 'file': 0.32; 'trouble': 0.34; 'objects': 0.35; 'data,': 0.36; 'method': 0.36; 'charset:us- ascii': 0.36; 'should': 0.36; 'list': 0.37; 'project': 0.37; 'skip:o 20': 0.38; 'presently': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'most': 0.60; 'save': 0.62; 'received:50.22': 0.84; 'subject:Fast': 0.84 |
| Date | Tue, 14 Jan 2014 08:18:33 -0600 |
| From | Tim Chase <python.list@tim.thechases.com> |
| To | python-list@python.org |
| Subject | Re: Python Fast I/o |
| In-Reply-To | <a9c545f2-fbc3-4ac4-81ee-a91f61c72b84@googlegroups.com> |
| References | <a9c545f2-fbc3-4ac4-81ee-a91f61c72b84@googlegroups.com> |
| X-Mailer | Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-AntiAbuse | This header was added to track abuse, please include it with any abuse report |
| X-AntiAbuse | Primary Hostname - boston.accountservergroup.com |
| X-AntiAbuse | Original Domain - python.org |
| X-AntiAbuse | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse | Sender Address Domain - tim.thechases.com |
| X-Get-Message-Sender-Via | boston.accountservergroup.com: authenticated_id: tim@thechases.com |
| 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 | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5462.1389712154.18130.python-list@python.org> (permalink) |
| Lines | 25 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1389712154 news.xs4all.nl 2950 [2001:888:2000:d::a6]:59721 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:63911 |
Show key headers only | View raw
On 2014-01-14 05:50, Ayushi Dalmia wrote:
> I need to write into a file for a project which will be evaluated
> on the basis of time. What is the fastest way to write 200 Mb of
> data, accumulated as a list into a file.
>
> Presently I am using this:
>
> with open('index.txt','w') as f:
> f.write("".join(data))
> f.close()
>
> where data is a list of strings which I want to dump into the
> index.txt file --
Most file-like objects should support a writelines() method which
takes an iterable and should save you the trouble of joining all the
content (and as Chris noted, you don't need the .close() since the
with handles it) so the whole thing would condense to:
with open('index.txt', 'w') as f:
f.writelines(data)
-tkc
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Python Fast I/o Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-01-14 05:50 -0800
Re: Python Fast I/o Chris Angelico <rosuav@gmail.com> - 2014-01-15 01:03 +1100
Re: Python Fast I/o Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-01-14 06:24 -0800
Re: Python Fast I/o Chris Angelico <rosuav@gmail.com> - 2014-01-15 01:32 +1100
Re: Python Fast I/o Roy Smith <roy@panix.com> - 2014-01-14 09:40 -0500
Re: Python Fast I/o Tim Chase <python.list@tim.thechases.com> - 2014-01-14 08:18 -0600
csiph-web