Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.037 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; '%s"': 0.07; 'calls.': 0.07; 'missed': 0.09; 'backwards': 0.09; 'iterate': 0.09; 'received:mail-qc0-f174.google.com': 0.09; 'cc:addr:python-list': 0.10; 'suggest': 0.11; 'backward': 0.16; 'forward:': 0.16; "function's": 0.16; 'file.': 0.20; "i'd": 0.22; 'cc:2**0': 0.23; "i've": 0.23; 'second': 0.24; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; 'functions.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'loop,': 0.29; 'could': 0.32; 'print': 0.32; 'certain': 0.33; 'front': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'faster': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'subject: (': 0.36; 'level': 0.37; 'two': 0.37; 'being': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'subject:-': 0.40; 'header:Received:5': 0.40; 'lower': 0.61; 'first': 0.61; 'back': 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=wR0ibgH6LtvdPmLFA8oP0OM6aaDEPJ2ZgpHD6ny50ik=; b=xPeZrUaYBzKF6VtBkQc2iMcAuMAaVO2WSbDw7xYcVih0gLGgePBr+wwYOwp2gk9E6u Bo8cJQkzSnwM/RxC2JB/NNeP6fbAIjTXHd08yKXgWwoF1d+WubfZ1tQ+QtfbSIr/u2Mb UuAzCt6NftDA2300o3qKtIF483AmQeOfR9VuAjnOx83/6wZHwWDaoeHl3G1WT1jeWmZZ dka6yFOLBtshsGVFBkQlhm5ABXEkkl423mItXu9e0Nlvpyqjg5g4hiGPAWlW7RNmXK2K MM/i9XtdW68smqdH+ATDnUJP5kkzSmihHrUXCvapLbgfYFlpBNhV8/Fvj1nX7Cyrw0Lo /j/A== MIME-Version: 1.0 In-Reply-To: References: <5086AA35.4000509@it.uu.se> Date: Tue, 23 Oct 2012 18:36:33 -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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351031796 news.xs4all.nl 6891 [2001:888:2000:d::a6]:42584 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31964 > 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 -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com