Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31949

Re: Fast forward-backward (write-read)

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'backwards': 0.09; 'cc:addr :python-list': 0.10; '-tkc': 0.16; '12:17,': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'inverse': 0.16; 'message- id:@tim.thechases.com': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'reversed': 0.16; 'wrote:': 0.17; 'variables': 0.17; 'tim': 0.18; '>>>': 0.18; 'file.': 0.20; 'assuming': 0.22; 'finally,': 0.22; 'cc:2**0': 0.23; 'example': 0.23; 'external': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; '---': 0.26; '(which': 0.26; 'order.': 0.27; 'question': 0.27; 'record': 0.28; 'chase': 0.29; 'separated': 0.29; 'smart': 0.29; '(and': 0.32; 'file': 0.32; 'could': 0.32; 'utility': 0.33; 'handle': 0.33; 'but': 0.36; 'subject: (': 0.36; 'data': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'sure': 0.38; 'subject:-': 0.40; 'your': 0.60; 'first': 0.61; 'provide': 0.62; 'details': 0.63; 'more': 0.63; 'reverse': 0.65; 'manner.': 0.66; 'received:50.22': 0.84; 'subject:Fast': 0.84; 'subject:read': 0.84; 'subject:write': 0.84
Date Tue, 23 Oct 2012 12:56:29 -0500
From Tim Chase <python.list@tim.thechases.com>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16
MIME-Version 1.0
To Virgil Stokes <vs@it.uu.se>
Subject Re: Fast forward-backward (write-read)
References <5086AA35.4000509@it.uu.se> <5086C156.40707@tim.thechases.com> <5086D13F.80006@it.uu.se>
In-Reply-To <5086D13F.80006@it.uu.se>
Content-Type text/plain; charset=ISO-8859-1
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-Source
X-Source-Args
X-Source-Dir
Cc "python-list@python.org" <python-list@python.org>
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.2681.1351014931.27098.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351014932 news.xs4all.nl 6960 [2001:888:2000:d::a6]:46911
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31949

Show key headers only | View raw


On 10/23/12 12:17, Virgil Stokes wrote:
> On 23-Oct-2012 18:09, Tim Chase wrote:
>>> Finally, to my question --- What is a fast way to write these
>>> variables to an external file and then read them in
>>> backwards?
>> Am I missing something, or would the fairly-standard "tac"
>> utility do the reversal you want?  It should[*] be optimized to
>> handle on-disk files in a smart manner.
> Not sure about "tac" --- could you provide more details on this
> and/or a simple example of how it could be used for fast reversed
> "reading" of a data file?

Well, if you're reading input.txt (and assuming it's one record per
line, separated by newlines), you can just use

  tac < input.txt > backwards.txt

which will create a secondary file that is the first file in reverse
order.  Your program can then process this secondary file in-order
(which would be backwards from your source).

I might have misunderstood your difficulty, but it _sounded_ like
you just want to inverse the order of a file.

-tkc




Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Fast forward-backward (write-read) Tim Chase <python.list@tim.thechases.com> - 2012-10-23 12:56 -0500

csiph-web