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


Groups > comp.lang.python > #32320

Re: Fast forward-backward (write-read)

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <vs@it.uu.se>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'binary': 0.05; 'float': 0.05; 'conversions': 0.07; 'pursuing': 0.07; 'array.': 0.09; 'backwards': 0.09; 'wraps': 0.09; 'file,': 0.15; 'benjamin': 0.16; 'binary.': 0.16; 'dave.': 0.16; 'inverse': 0.16; 'mapped': 0.16; 'mmap': 0.16; 'numpy': 0.16; 'query,': 0.16; 'simplest': 0.16; 'time"': 0.16; 'wrote:': 0.17; 'bytes': 0.17; '>>>': 0.18; 'windows': 0.19; 'issue.': 0.20; 'to:name:python-list@python.org': 0.20; 'import': 0.21; '4.0': 0.22; "i'd": 0.22; 'paul': 0.24; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; '---': 0.26; 'am,': 0.27; 'post': 0.28; 'record': 0.28; '>>>>': 0.29; 'writes:': 0.29; 'file': 0.32; 'function.': 0.33; 'handle': 0.33; 'to:addr:python-list': 0.33; 'thanks': 0.34; 'really': 0.36; 'but': 0.36; 'subject: (': 0.36; 'possible': 0.37; 'october': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'performance': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'little': 0.39; 'received:192.168': 0.40; 'subject:-': 0.40; 'think': 0.40; 'map': 0.61; 'first': 0.61; "you'll": 0.62; 'skip:n 10': 0.63; 'more': 0.63; 'tricks': 0.65; 'forward': 0.66; 'wish': 0.70; 'now...': 0.84; 'oscar': 0.84; 'subject:Fast': 0.84; 'subject:read': 0.84; 'subject:write': 0.84; 'findings': 0.91; 'try.': 0.91; 'angel': 0.93
X-SENDER-IP [213.112.50.224]
X-LISTENER [smtp.bredband.net]
X-IronPort-Anti-Spam-Filtered true
X-IronPort-Anti-Spam-Result AqwmAOGyjVDVcDLgPGdsb2JhbAANN4pSuCcBAQEBOIJSAQEBAQMnEUARCxgJFg8JAwIBAgExBgENBg0GAgEBsDCSV4t1hl0DkkKWZIFaJA
X-IronPort-AV E=Sophos;i="4.80,668,1344204000"; d="scan'208";a="214724239"
Date Sun, 28 Oct 2012 23:36:04 +0100
From Virgil Stokes <vs@it.uu.se>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version 1.0
To "python-list@python.org" <python-list@python.org>
Subject Re: Fast forward-backward (write-read)
References <5086AA35.4000509@it.uu.se> <5086C156.40707@tim.thechases.com> <5086D13F.80006@it.uu.se> <5086DA4D.4060204@tim.thechases.com> <mailman.2683.1351018926.27098.python-list@python.org> <7xr4ooah0t.fsf@ruckus.brouhaha.com> <50879555.7000200@it.uu.se> <508D1469.5060109@davea.name> <508D3F3D.9020303@it.uu.se> <CAHVvXxRFvGu=zph223xqpWejB6a185ZpW0fw1amHipHvO-Bhrg@mail.gmail.com>
In-Reply-To <CAHVvXxRFvGu=zph223xqpWejB6a185ZpW0fw1amHipHvO-Bhrg@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
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.2978.1351463769.27098.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351463769 news.xs4all.nl 6907 [2001:888:2000:d::a6]:35693
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32320

Show key headers only | View raw


On 2012-10-28 19:21, Oscar Benjamin wrote:
> On 28 October 2012 14:20, Virgil Stokes <vs@it.uu.se> wrote:
>> On 28-Oct-2012 12:18, Dave Angel wrote:
>>> On 10/24/2012 03:14 AM, Virgil Stokes wrote:
>>>> On 24-Oct-2012 01:46, Paul Rubin wrote:
>>>>> Virgil Stokes <vs@it.uu.se> writes:
>>>>>> Yes, I do wish to inverse the order,  but the "forward in time" file
>>>>>> will be in binary.
>>>>> I really think it will be simplest to just write the file in forward
>>>>> order, then use mmap to read it one record at a time.  It might be
>>>>> possible to squeeze out a little more performance with reordering tricks
>>>>> but that's the first thing to try.
>>>> Thanks Paul,
>>>> I am working on this approach now...
>>> If you're using mmap to map the whole file, you'll need 64bit Windows to
>>> start with.  I'd be interested to know if Windows will allow you to mmap
>>> 100gb at one stroke.  Have you tried it, or are you starting by figuring
>>> how to access the data from the mmap?
>> Thanks very much for pursuing my query, Dave.
>>
>> I have not tried it yet --- temporarily side-tracked; but, I will post my
>> findings on this issue.
> If you are going to use mmap then look at the numpy.memmap function.
> This wraps pythons mmap so that you can access the contents of the
> mapped binary file as if it was a numpy array. This means that you
> don't need to handle the bytes -> float conversions yourself.
>
>>>> import numpy
>>>> a = numpy.array([4,5,6], numpy.float64)
>>>> a
> array([ 4.,  5.,  6.])
>>>> with open('tmp.bin', 'wb') as f:  # write forwards
> ...   a.tofile(f)
> ...   a.tofile(f)
> ...
>>>> a2 = numpy.memmap('tmp.bin', numpy.float64)
>>>> a2
> memmap([ 4.,  5.,  6.,  4.,  5.,  6.])
>>>> a2[3]
> 4.0
>>>> a2[5:2:-1] # read backwards
> memmap([ 6.,  5.,  4.])
>
>
> Oscar
Thanks Oscar!

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


Thread

Re: Fast forward-backward (write-read) Virgil Stokes <vs@it.uu.se> - 2012-10-23 20:37 +0200
  Re: Fast forward-backward (write-read) Paul Rubin <no.email@nospam.invalid> - 2012-10-23 16:46 -0700
    Re: Fast forward-backward (write-read) Dave Angel <d@davea.name> - 2012-10-28 07:18 -0400
    Re: Fast forward-backward (write-read) Virgil Stokes <vs@it.uu.se> - 2012-10-28 15:20 +0100
    Re: Fast forward-backward (write-read) Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-10-28 18:21 +0000
    Re: Fast forward-backward (write-read) Virgil Stokes <vs@it.uu.se> - 2012-10-28 23:36 +0100

csiph-web