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


Groups > comp.lang.python > #108211

Re: Pylint prefers list comprehension over filter...

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Pylint prefers list comprehension over filter...
Date Fri, 6 May 2016 12:55:05 +1000
Lines 24
Message-ID <mailman.425.1462503307.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> <CAPTjJmqJmkTp85wWZm_GF1gRKSRv5UE7Ck4jZM2NBSwAnFKk-Q@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de SvvnHgB2GQVkeiWd4mXxCgmbfD3TaX67tmUDZ4CgAPWg==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:skip:c 10': 0.07; 'cc:addr:python-list': 0.09; '[1,': 0.09; 'python': 0.10; '2.7': 0.13; '2016': 0.16; '3.0,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterables': 0.16; 'iterated': 0.16; 'range,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'changes': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'accepted.': 0.20; '(where': 0.23; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'subject:list': 0.26; 'linux': 0.26; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'dan': 0.29; "i'm": 0.30; 'lists': 0.34; 'received:google.com': 0.35; 'filter': 0.35; 'happened': 0.35; 'returning': 0.35; 'stopped': 0.35; 'but': 0.36; 'too': 0.36; 'list,': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'things': 0.38; 'received:209': 0.38; 'means': 0.39; 'build': 0.40; 'where': 0.40; 'more': 0.63; "they're": 0.66; '5.3.1': 0.84; 'chrisa': 0.84; 'subject:over': 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=AIWA0rvcuDflhCEDs2vvbACf3pFdz+rhBgzAKSC26zw=; b=wg7cw0wTZ1BYCESZTnTcqOK+yHQkRTeG6C6kxzzJNGhebaVp0ItVVdZBeSdi/OwOEV XQyzkXxhDBTIpRAlm2mY+HvgUMHNYE4D8HSaj9btBO1UklA5uSBqdswJU9rGYeDmu/gU cacewlz1JekcyV4DGHw4rPb5iUNZDb6f04W828bTKyyQQAmuTaNBm6yWPKtoInjgjhIS 1Fue33fbK5WFjQrbAKu2/VNq4xKQtkFmY2tjxefOel7jbRK1VSCWkSj0PrX76IGRIbQ0 2boEUT4ZgmStYOTxEYTI0ecw8bYE+gDjJYbya0UnLX4XUKBYuYHpyaZn4mkKbP2yYE96 s6zw==
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=AIWA0rvcuDflhCEDs2vvbACf3pFdz+rhBgzAKSC26zw=; b=FgDUdziSLF0w4GvtRqqBSrz2qi0p8hK23v+3HZo7ciwIK81rZVElaYeo5pcl0Q83bd 2mrzgfVIY+J0sPII7hc9+/4fGrKQhDqk2XWOp5WvSSP9f9lxgxtReP1ubIfsGQjOtBfc H0LxMBiLAhi2GvtcPEP1+EANB/i29bTgPP6+dLxg7GS5sHekpwMCEd3xX36L5231w0oE oQEJJplcZA6T2+PPO9Cx1CAFtSYmpLl+BwLKIuzF0Nd8gnhbFcIUwNcrARBtiPo2w5lR CdJDb2YPUbhIeBUfUL5O6ozYDBqP+sE7suw0vaJTOLSM/8UVVdGNsHK9ScdaR+Pk6RYW oeVQ==
X-Gm-Message-State AOPr4FXXLrWhq+JZvKgfS16XYqFHr6L+4JimQJ0O6xeNg38JOe6kU6Ut2G/FrCbMv7kfnW/giVn84/S+mmbwow==
X-Received by 10.25.80.72 with SMTP id e69mr8500376lfb.96.1462503305696; Thu, 05 May 2016 19:55:05 -0700 (PDT)
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 <CAPTjJmqJmkTp85wWZm_GF1gRKSRv5UE7Ck4jZM2NBSwAnFKk-Q@mail.gmail.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:108211

Show key headers only | View raw


On Fri, May 6, 2016 at 12:46 PM, Dan Sommers <dan@tombstonezero.net> wrote:
> 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):
>
>     Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
>     [GCC 5.3.1 20160409] on linux2
>     Type "help", "copyright", "credits" or "license" for more information.
>     >>> filter(lambda x:x+1, [1, 2, 3, 4])
>     [1, 2, 3, 4]
>
>     Python 3.5.1+ (default, Apr 17 2016, 16:14:06)
>     [GCC 5.3.1 20160409] on linux
>     Type "help", "copyright", "credits" or "license" for more information.
>     >>> filter(lambda x:x+1, [1, 2, 3, 4])
>     <filter object at 0x7f26a9ef3320>

Most of these kinds of changes happened in 3.0, where
backward-incompatible changes were accepted. A whole bunch of things
stopped returning lists and started returning lazy iterables - range,
filter/map, dict.keys(), etc - because most of the time, they're
iterated over once and then dropped.

ChrisA

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