Path: csiph.com!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.kamp.net!newsfeed.kamp.net!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:38:52 +1100 Lines: 29 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 Mfn/Xoc6qMR+/ybX82IoxwMy2518VthXLfaIq9MY/BhQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '"""': 0.05; 'option,': 0.07; 'cc:addr:python-list': 0.09; 'subject:which': 0.09; 'yeah,': 0.09; 'wed,': 0.15; '2016': 0.16; '23,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'itertools': 0.16; 'negates': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:?)': 0.16; 'write,': 0.16; 'wrote:': 0.16; 'case.': 0.18; 'exists': 0.18; 'people,': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'filtering': 0.22; 'trying': 0.22; 'am,': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'sort': 0.25; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; "i'm": 0.30; 'usually': 0.33; 'that!': 0.33; 'received:google.com': 0.35; 'next': 0.35; 'could': 0.35; 'generic': 0.35; 'sometimes': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'things': 0.38; 'received:209': 0.38; 'stuff': 0.38; 'does': 0.39; "didn't": 0.39; 'subject:The': 0.61; 'grab': 0.64; 'mar': 0.65; 'course.': 0.67; 'worth': 0.67; '--->': 0.84; 'chrisa': 0.84; 'flexibility,': 0.84; 'type(s)': 0.84; 'to:none': 0.91; '(full': 0.91; 'str.': 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=rRhkyH8GT6mxh6+CLB+fUh7gSYILK7IvDTfWEVlaFlI=; b=0GtjiiTot5fHgzyiC5kFIk40/9rqV4OZG1NHTxQBv7gbvdocA72if14N2SbB2goYi2 HIeg63A+UoFy9PWyr1O4V8bFV3/Uf1fR4y8PVacoWQ0cB5O/vwW/7if+XndTJwxufr4/ 66tu3uxmfMJyDbmlFfloH/S/rnHKzEl6OV9ZbrpqhrVeD+6YQTHQ/nQ3LTz4NQPOXiO0 f8RGdW9bzu/TwixDXUP3FoS45yXdcRFfzf7GJJdnjjBUcg1Zj7SQn5oXizmSxeQ+KEfK CB+u9PVPFGgxe5rqQ16UItzYd0qhLtfy+ESc0Fvz8Z9+QdJw4dtBwp/4Gpu59PLw1NQw NYUg== 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=rRhkyH8GT6mxh6+CLB+fUh7gSYILK7IvDTfWEVlaFlI=; b=OyaNOvyiqevgXsTonCLqE1Q2SkuwxOeakrUL1EEBY6Taq/Z7viTFAhu3ur/kuIKvDr x2mYHKwx0gM0wGqdcpv5BLD8udxSFnHwOteheKYDS9PO+ikRZCql/j+aQ+u96Jwsta4B 3zGpTMGuOrBSVGzV7rKCjhlyVs4geUdh6hEZj3NqNr3bHeIhSGiFJVUtiKM/+Ec9p2fC CYhO6LRhQltwqnXPA8zehw970AAr0HEXtW0LQcYrW2RiSZcGG76Df7F+n5gMPaku+pfq qpfmFngEodX625nE8ouZNCxVpvBMLnmT2EhNl7lyzCs2AMH2AB3bS81w2IK0MwRiZ/xt ph0A== X-Gm-Message-State: AD7BkJI6ueDXozDyucYxwtQqAMr/ElI3YgaNx8hlSPkdunbBzCbYf7T1OGy1gdD164uCcIJ+UhKfjhcvVEdE3g== X-Received: by 10.25.78.137 with SMTP id c131mr10771768lfb.21.1458653932353; Tue, 22 Mar 2016 06:38:52 -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:105485 On Wed, Mar 23, 2016 at 12:32 AM, Jussi Piitulainen wrote: >> Although I do sometimes yearn for a "filterout" function that does the >> same thing as filter() but negates its predicate. Then you could use: >> >> next(filterout(str.isspace, stream)) >> >> to say "give me the next from the stream, filtering out those which >> are spaces". It's not hard to write, of course. > > from itertools import filterfalse as filterout > > next(filterout(str.isspace, """ > > I didn't know str.isspace works like that! > > """)) > ---> 'I' str.isspace(s) <-> s.isspace(), as long as type(s) is str. Very handy for this sort of thing. And yeah, the import is an option, but if I'm trying to explain stuff to people, it's usually easier to grab a genexp (full flexibility, but the complexity) than to play around with importing. When the function you want exists and returns true for the things you want, filter() has a big win; for any other situation, it's not worth reaching to itertools for a specific solution when the generic one will cover this and every other case. ChrisA