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


Groups > comp.lang.python > #32013 > unrolled thread

Re: Fast forward-backward (write-read)

Started byDavid Hutto <dwightdhutto@gmail.com>
First post2012-10-24 03:19 -0400
Last post2012-10-24 03:19 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Fast forward-backward (write-read) David Hutto <dwightdhutto@gmail.com> - 2012-10-24 03:19 -0400

#32013 — Re: Fast forward-backward (write-read)

FromDavid Hutto <dwightdhutto@gmail.com>
Date2012-10-24 03:19 -0400
SubjectRe: Fast forward-backward (write-read)
Message-ID<mailman.2736.1351063174.27098.python-list@python.org>
On Wed, Oct 24, 2012 at 3:05 AM, Virgil Stokes <vs@it.uu.se> wrote:
> On 24-Oct-2012 00:36, David Hutto wrote:
>>>
>>> Don't forget to use timeit for an average OS utilization.
>>>
>>> I'd suggest two list comprehensions for now, until I've reviewed it some
>>> more:
>>>
>>> forward =  ["%i = %s" % (i,chr(i)) for i in range(33,126)]
>>> backward = ["%i = %s" % (i,chr(i)) for i in range(126,32,-1)]
>>>
>>> for var in forward:
>>>          print var
>>>
>>> for var in backward:
>>>          print var
>>>
>>> You could also use a dict, and iterate through a straight loop that
>>> assigned a front and back to a dict_one =  {0 : [0.100], 1 : [1.99]}
>>> and the iterate through the loop, and call the first or second in the
>>> dict's var list for frontwards , or backwards calls.
>>>
>>>
>>> But there might be faster implementations, depending on other
>>> function's usage of certain lower level functions.
>>>
>> Missed the part about it being a file. Use:
>>
>> forward =  ["%i = %s" % (i,chr(i)) for i in range(33,126)]
>> backward = ["%i = %s" % (i,chr(i)) for i in range(126,32,-1)]
>>
>> print forward,backward
>
> Interesting approach for small data sets (or blocks from a much larger data
> set).
>
> Thanks David :-)

No problem.

I think this was for a > 100GB, which might be able to be reduced for
parsing if I could see a snippet of the usual data being processed by
the function

But it does go to big O notation, and optimization of the average data
being passed through, unless the data varies in wide ranges, in which
that could be optimized to go from smaller to larger, vice versa, or
othe pieces of data with a higher priority level..




-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web