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: Wed, 23 Mar 2016 00:00:25 +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> <56f09973$0$1601$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de ian7667Wy4XxA0YdH5szBg+qSVnJKwGel4YmgxK/1xZg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'cc:addr:python-list': 0.09; '22,': 0.09; 'expression:': 0.09; 'subject:which': 0.09; 'def': 0.13; "'*'": 0.16; "'/'": 0.16; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:?)': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'probably': 0.31; 'stream': 0.33; 'symbol': 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'next': 0.35; 'item': 0.35; 'sometimes': 0.35; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'subject:The': 0.61; 'skip:n 10': 0.62; 'more': 0.63; 'mar': 0.65; 'here': 0.66; '--->': 0.84; 'chrisa': 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=YRAuyuSi00QebzZ90beIZKIZ+AZ8cSm3PAYxxrH0fqE=; b=gNFbCq+vsQrfiWBgHaCwiNTlKl4zFAJR4J6TL70W+Si94v/ZTc+5LYNKay5HdH9CCK PWm6RNw5NzNj+34v8WRWxSKt3E3wyLhel72GgHkNuElS/db8AuBHt1h83w69Ojsxlfp5 DsvTQdADpZqIR/cVzomVdr2vphdPSe5WzQuKZ872KN5bdKDNzqWQKsQe5UCxcda9/0jJ omTYDpemGDaxh65P/st+ba/TbjLUcDZScRCSu7TysHebyUpQgoMNe8ng5pDdowtTLUhm AUp0R6/ejCZyGDVCG9qkxyUHNxMRs3KoxeGqgvoBbCeYc3DjCyjI7MF+z/j7rafQryEx n4hw== 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=YRAuyuSi00QebzZ90beIZKIZ+AZ8cSm3PAYxxrH0fqE=; b=mmCOQh1/KuchyNAvrBu+EQbUOIgx6zroebxFWBgNbJpicSw/E7/IzY2Z2R5tjPEPeY KnZw8RH+z3CI4Cecv0ZRKpaXW7Wugk9CoanXJXEu6U3xn3KG98NtFcXdB11m9xj6R6FD pQnyek8w8Vobz+Eui4divK5n6v8+fdmRWCuxW15O/POBUOF4MMX/pVJtVZh4nckaNsgi R9rfnxINEMQNqQIfyjlqGAJElnimv32yOfS7OB6VfpRKxjsW1kPdDBnXNAIU5ZPsG6Ij jRbvYwWDfbx6kh3luoaB3ZCCDM7BKPnMGm3gcfk/160OYagbH/wH5EViL0wL72+j6bMi d4Pg== X-Gm-Message-State: AD7BkJKJsDFZNLxF3vXc5p/CWoHlNYKCPxBCr2f9xw3h+RkltRJYS7S0NUY2+KTTzjCr2qiFUH8xiZf+FgwX0w== X-Received: by 10.25.156.196 with SMTP id f187mr13228663lfe.150.1458651625607; Tue, 22 Mar 2016 06:00:25 -0700 (PDT) In-Reply-To: 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:105477 On Tue, Mar 22, 2016 at 11:52 PM, Jussi Piitulainen wrote: > Now you can ask for the next item that satisfies a condition using a > generator expression: > > next(symbol for symbol in stream if not symbol.isspace()) > ---> '/' > > next(symbol for symbol in stream if not symbol.isspace()) > ---> '*' Or use filter(), which is sometimes clearer: # You probably want a more sophisticated function here def nonspace(ch): return not ch.isspace() next(filter(nonspace, stream)) ChrisA