Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'processed': 0.05; '%s"': 0.07; 'calls.': 0.07; 'parsing': 0.07; 'missed': 0.09; 'backwards': 0.09; 'iterate': 0.09; 'snippet': 0.09; 'through,': 0.09; 'cc:addr:python-list': 0.10; 'suggest': 0.11; ':-)': 0.13; '24,': 0.16; 'backward': 0.16; 'blocks': 0.16; 'forward:': 0.16; "function's": 0.16; 'larger,': 0.16; 'notation,': 0.16; 'oct': 0.16; 'varies': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'pieces': 0.17; '>>>': 0.18; '(or': 0.18; 'file.': 0.20; 'received:209.85.216.46': 0.21; "i'd": 0.22; 'cc:2**0': 0.23; 'sets': 0.23; "i've": 0.23; 'second': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'functions.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'loop,': 0.29; 'priority': 0.29; 'reduced': 0.29; 'function': 0.30; 'problem.': 0.32; 'could': 0.32; 'print': 0.32; 'certain': 0.33; 'front': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'list': 0.35; 'faster': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'smaller': 0.36; 'subject: (': 0.36; 'optimization': 0.37; 'does': 0.37; 'level': 0.37; 'two': 0.37; 'being': 0.37; 'passed': 0.37; 'usual': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'subject:-': 0.40; 'header:Received:5': 0.40; 'think': 0.40; 'lower': 0.61; 'first': 0.61; 'back': 0.62; 'wide': 0.62; 'forward': 0.66; 'reviewed': 0.74; 'dict,': 0.84; 'more:': 0.84; 'subject:Fast': 0.84; 'subject:read': 0.84; 'subject:write': 0.84; 'average': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Pc7QqC2AcwGd3jF0MFL2K6SKJHSVu9h8gg3s40UkS0s=; b=EBGBhCAsLtOxVZIvwZu3ba8OIP3jHFHLK+QVibdWr99wVjCWABZcebU3RXzH+lXnat C6wbMbqbcS0tx+44rHvMRqelqsA0+aGqC7xZiH13Vwjr9dV7nAA2lkQCjX15ffZCoYPY AEt8GCW55/G4HGNTRezs/QMYJBO0mvwrt6hyHKxeoDxoBBpMzzHh7JtyBpaaqg5I/IuX Iy/XwyWyb7jHw3ze6WNJaypj//IIzp2UZ4OY1Xgcdo16AYH/+JFEhJQOCEqLxjkyT7xf L54mNxl48GP4nfBX50P7CWc3LF+2mhu2HVvLrrqo4ZgpxWpSmoV7JwINO3Op3iySlx2o 6fiA== MIME-Version: 1.0 In-Reply-To: <50879342.5030301@it.uu.se> References: <5086AA35.4000509@it.uu.se> <50879342.5030301@it.uu.se> Date: Wed, 24 Oct 2012 03:19:30 -0400 Subject: Re: Fast forward-backward (write-read) From: David Hutto To: Virgil Stokes Content-Type: text/plain; charset=ISO-8859-1 Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 56 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351063174 news.xs4all.nl 6873 [2001:888:2000:d::a6]:55115 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32013 On Wed, Oct 24, 2012 at 3:05 AM, Virgil Stokes 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