Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #108213

Re: Pylint prefers list comprehension over filter...

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Stephen Hansen <me+python@ixokai.io>
Newsgroups comp.lang.python
Subject Re: Pylint prefers list comprehension over filter...
Date Thu, 05 May 2016 19:57:26 -0700
Lines 19
Message-ID <mailman.426.1462503449.32212.python-list@python.org> (permalink)
References <572BF2BF.6000000@icloud.com> <1462498631.232041.599637409.25D91C08@webmail.messagingengine.com> <mailman.422.1462498634.32212.python-list@python.org> <ngh0hu$4og$1@dont-email.me> <1462503446.248479.599683745.79791DAC@webmail.messagingengine.com>
Mime-Version 1.0
Content-Type text/plain
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de hTHJTTemCZ4w7f2/iirNQQYMP9ziZAxVFMvx+wraDDeA==
Return-Path <me+python@ixokai.io>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'needed,': 0.05; 'subject:skip:c 10': 0.07; 'oh,': 0.09; 'received:internal': 0.09; 'python': 0.10; '2.7': 0.13; 'output': 0.13; 'thu,': 0.15; '2016': 0.16; 'list*': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'skips': 0.16; 'wrote:': 0.16; 'string': 0.17; 'stephen': 0.22; '(where': 0.23; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'subject:list': 0.26; 'converting': 0.27; '-0700,': 0.29; 'dan': 0.29; "i'm": 0.30; 'that.': 0.30; 'list': 0.34; 'filter': 0.35; 'returning': 0.35; 'but': 0.36; 'too': 0.36; 'list,': 0.36; 'instead': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'difference': 0.38; 'received:66': 0.38; 'building': 0.38; 'means': 0.39; "didn't": 0.39; 'build': 0.40; 'to:addr:python.org': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.61; 'subject:over': 0.84
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=ixokai.io; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=6pGP2yXW7wBaAYG7mrHGm4Yst84=; b=eVFkBG UnkgdIvWifKE7VXuYYD8CttWqMicjAPPchlDXn/p1DvedjMDngD3sq+VYeUwj9mN Poxh6JzIGXgnwJv/jrJ1xfETuPGiseyIBCmCkRhpJf9zU1zdwjHsGG/uXZA7F55i zeUXYjS0l1sHfnvlEdWsEc32C5E8F3JedcuhQ=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=6pGP2yXW7wBaAYG 7mrHGm4Yst84=; b=E1hlKPI+n2DTBXZcG8q4QWteRWGWsWLpvs94iOx0k1N/SDX bZAEXuIFTNPPfhUZ8jFtojude3jIFnVFMuezNSUAyNu85gSR5w6X2QMc4oyL/R5w X+TSuyaII9+TcfIVtdTdjig5dlBcCqcTRb5NKVcYnkJJTuFH7LBxM5TqmMAA=
X-Sasl-Enc P7UmBGVrNDYUJrxtHHOSQTAvF4jmUaGMH3MvcuBB4gSr 1462503446
X-Mailer MessagingEngine.com Webmail Interface - ajax-140377c4
In-Reply-To <ngh0hu$4og$1@dont-email.me>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <1462503446.248479.599683745.79791DAC@webmail.messagingengine.com>
X-Mailman-Original-References <572BF2BF.6000000@icloud.com> <1462498631.232041.599637409.25D91C08@webmail.messagingengine.com> <mailman.422.1462498634.32212.python-list@python.org> <ngh0hu$4og$1@dont-email.me>
Xref csiph.com comp.lang.python:108213

Show key headers only | View raw


On Thu, May 5, 2016, at 07:46 PM, Dan Sommers wrote:
> On Thu, 05 May 2016 18:37:11 -0700, Stephen Hansen wrote:
> 
> >     ''.join(x for x in string if x.isupper())
> 
> > The difference is, both filter and your list comprehension *build a
> > list* which is not needed, and wasteful. The above skips building a
> > list, instead returning a generator ...
> 
> filter used to build a list, but now it doesn't (where "used to" means
> Python 2.7 and "now" means Python 3.5; I'm too lazy to track down the
> exact point(s) at which it changed):

Oh, didn't know that. Then again the OP was converting the output of
filter *into* a list, which wasted a list either way.

-- 
Stephen Hansen
  m e @ i x o k a i . i o

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Pylint prefers list comprehension over filter... Stephen Hansen <me@ixokai.io> - 2016-05-05 18:37 -0700
  Re: Pylint prefers list comprehension over filter... Dan Sommers <dan@tombstonezero.net> - 2016-05-06 02:46 +0000
    Re: Pylint prefers list comprehension over filter... Chris Angelico <rosuav@gmail.com> - 2016-05-06 12:55 +1000
    Re: Pylint prefers list comprehension over filter... Stephen Hansen <me+python@ixokai.io> - 2016-05-05 19:57 -0700
      Re: Pylint prefers list comprehension over filter... Steven D'Aprano <steve@pearwood.info> - 2016-05-06 22:42 +1000
    Re: Pylint prefers list comprehension over filter... Dan Sommers <dan@tombstonezero.net> - 2016-05-06 03:07 +0000
      Re: Pylint prefers list comprehension over filter... Chris Angelico <rosuav@gmail.com> - 2016-05-06 13:18 +1000
    Re: Pylint prefers list comprehension over filter... Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-07 12:37 -0700

csiph-web