Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!news.osn.de!diablo2.news.osn.de!news.tele.dk!news.tele.dk!small.news.tele.dk!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.114 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.77; '*S*': 0.00; 'string': 0.09; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'letters.': 0.16; 'scalable,': 0.16; 'simple.': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'wed,': 0.18; 'typing': 0.19; 'input': 0.22; 'rapidly': 0.24; 'fairly': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; '(like': 0.30; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'reply.': 0.31; 'with,': 0.31; 'becomes': 0.33; 'there,': 0.34; 'core': 0.34; 'maybe': 0.34; "i'd": 0.34; 'problem.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'doubt': 0.36; 'thanks': 0.36; 'performance': 0.37; 'nov': 0.38; 'needed': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'commands': 0.60; 'simple': 0.61; 'talking': 0.65; 'million': 0.74; '100': 0.79; 'cpu,': 0.84; 'syed': 0.84; 'hundred': 0.95; '2013': 0.98 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 :content-type; bh=OTWWm0h06y0o+fR66m4oXvBGMO3vZxP19V/J0550Ayk=; b=F87gXxLPHJu72Z5A3rABAmQYTTMa7Jv1qJDXnqXIIwMopQvMokee1wGjqi3P9zxja7 6bdIVlOMyx2fAjmf8SuJNjAzdUjuriXen26ffQwoAyBV72dLN1hzNSjSa/fnPBY7xP2h smmZLzJN8PdeU0eItw5UtD3Vu2zkjNr8biTzU40lD8y0grhuOHQZOTNnM4PjAToDmTZH aAk/TQAXiY7N0VC1fVZ0N1faZPaTRYR+NtxaNV7v2JB67vh65qIlvWkm8FhSyiF4TAh8 LIUNyzF2iJrfPNTNndHokyL494u7/8u5y2rlybKZAhdt2pSg1oLOqwpNtuSggAR+e3ru wvsQ== MIME-Version: 1.0 X-Received: by 10.69.31.1 with SMTP id ki1mr4498526pbd.124.1385550858118; Wed, 27 Nov 2013 03:14:18 -0800 (PST) In-Reply-To: References: <35a56651-33b3-454e-a936-439196989d3b@googlegroups.com> Date: Wed, 27 Nov 2013 22:14:18 +1100 Subject: Re: Wrapping around a list From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385550867 news.xs4all.nl 15885 [2001:888:2000:d::a6]:56848 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60594 On Wed, Nov 27, 2013 at 10:07 PM, Amjad Syed wrote: > Thanks Chris for the reply. But i would like sliding function to be scalable, as input string can be of 100 letters. A hundred isn't much to work with, and your code will be fairly simple. Give it a try with small strings, see how it goes; then try it on your full-size - I doubt there'll be a problem. Now, if you were talking about a hundred million letters, then maybe there'd be a problem. But even there, I'd start with the simple and clean approach, and only optimize for performance when it becomes obviously necessary (like when my MUD client was able to saturate one core of my CPU, just by me typing a lot of commands very rapidly - that needed fixing!). ChrisA