Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?) Date: Thu, 24 Mar 2016 11:15:42 +1100 Lines: 19 Message-ID: References: <56e44258$0$1598$c3e8da3$5496439d@news.astraweb.com> <8737rvxs89.fsf@elektro.pacujo.net> <56e7483d$0$1608$c3e8da3$5496439d@news.astraweb.com> <56ef9787$0$1516$c3e8da3$5496439d@news.astraweb.com> <56f02196$0$1588$c3e8da3$5496439d@news.astraweb.com> <56f32cff$0$1602$c3e8da3$5496439d@news.astraweb.com> <1458778332.487148.558100370.607E9944@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de chJ3jdwmdrSYVx96YcB7HANqUTTgL177vf7nLevbEa+w== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; 'pop': 0.05; 'file)': 0.07; 'cc:addr:python-list': 0.09; 'stringio': 0.09; 'subject:which': 0.09; 'thu,': 0.15; '2016': 0.16; '24,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterator': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:?)': 0.16; 'true:': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'string': 0.17; 'string,': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '(the': 0.22; 'am,': 0.23; 'for?': 0.23; 'header:In-Reply-To:1': 0.24; 'sense': 0.26; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'loop,': 0.29; 'tail': 0.29; 'them?': 0.29; 'code': 0.30; 'guess': 0.31; 'class': 0.33; 'source': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.35; "isn't": 0.35; 'received:209.85': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'copying': 0.38; 'where': 0.40; 'care': 0.60; 'your': 0.60; 'subject:The': 0.61; 'real': 0.62; 'further': 0.62; 'more': 0.63; 'world': 0.64; 'grab': 0.64; 'mar': 0.65; 'chrisa': 0.84; 'handing': 0.84; 'or...': 0.84; 'to:none': 0.91 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:cc; bh=QrAVwxzYBbh9mU7A7j3j0Xn3G2XdAp7wJXBPTBn/lP4=; b=i+ClEoZ/d52bLcYqXNlneMvXO/2YcQZSQMkrXXYTaFKWht7dK4kjwYdW4ZhjpEW53M E68EFw6z/+hxT600zJZ2Uya7L5iNeX1Gb6uB+5YOGS7QBHGh5vKsiSmWSoeYlzrHEqvm aJ4j4PD14eCS8OkEGSKutUyQhig9s5kn7LkGC59OGkT7HEycm8AMlUphtYwsvku9oKc/ GJCTB87rqIRX50qPHmGEyEQUFoJnotZBzREYmjZKCpIbJ4hb5EKq+kJgFaXLbzhUHfKu W1MeJxVc7KyifjKUKOgfk8VYd7TxcYcfBrFi9Ks+ENrwuFE46azb56L3UDG0WVu0kM28 G20A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=QrAVwxzYBbh9mU7A7j3j0Xn3G2XdAp7wJXBPTBn/lP4=; b=W6wtiOV4bvUPUZaaZJ87Aoi5BYRxlZcFZz+mAzD8KYmtjGdrVyAeISkM0NvDUT/cAe DYq33OubD1HhnfyIIw5e+HVwrO8jjbggp/as0cA1nnFb+q2cXL40qDBQ3WjiExMJcoES cSCV3BNBZk40cb+wbEYjhCC35QiBF8Wfv8P8k8+IkO5sNtdiLlUVKOikyQvXvHwlY0oP 9kfcOzXO3d2Ccep9ZvqCluzOaeZ3bOUmY9M3d8kn9A5Zx4QQHGO/OBl3ktiUP6Xwtr1R 1/dN62Eo8mJuikMR+kBaLenlbF17Wf+ZYpwL5I435l1brm2+BnmHrtnCxOJSf7PD9UYE pmMw== X-Gm-Message-State: AD7BkJK+8f5nSAD7AzPnCpEjMnUgnHN5OR9697ffiB4VIgnRYSMJcL5MHW4YiVvaV7aVh8t6o/YKKB4pqo24fQ== X-Received: by 10.107.169.105 with SMTP id s102mr5886511ioe.19.1458778543038; Wed, 23 Mar 2016 17:15:43 -0700 (PDT) In-Reply-To: <1458778332.487148.558100370.607E9944@webmail.messagingengine.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105577 On Thu, Mar 24, 2016 at 11:12 AM, Random832 wrote: > I guess the question is, what do you _actually_ need the tail string > for? If you're using it in a loop, to pop further characters from (the > scenario that would cause it to be copying the string over lots of > times), wouldn't it make more sense to use a StringIO (or, in the real > world where your C source code isn't a string, a file) and let that > class take care of handing out characters when you ask for them? > > Like... > > fsource = StringIO(psource) > > while True: > c = fsource.read(1) > lxsymbol = disptable[min(ord(c), 256)](c, fsource) Or... just grab an iterator off the string and call next() on it? ChrisA