[issue25840] Allow `False` to be passed to `filter`

2015-12-11 Thread leewz

New submission from leewz:

Meaning:

filter(False, lst)
== (x for x in lst if not x)
== itertools.filterfalse(None, lst)

I understand that it is a very minor enhancement, and with not much benefit. I 
just happened to think about it, and wondered why it didn't already exist. I 
figured it wouldn't hurt to put the idea out here.

(If anyone is interested, I was looking into ways that filter/map/itertools 
could "unwrap" each other at the C level to improve composition of generators, 
inspired by the functools.partial optimization.)

--
messages: 256218
nosy: leewz
priority: normal
severity: normal
status: open
title: Allow `False` to be passed to `filter`
type: enhancement
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25840] Allow `False` to be passed to `filter`

2015-12-11 Thread R. David Murray

R. David Murray added the comment:

I don't think it is worth adding as a special case.  Itertools has it because 
of what itertools is (a mini-language for manipulating iterables), but the 
legacy filter function has no reason to grow additional special cases beyond 
None.  (It's not even clear why it has that one special case :)

--
nosy: +r.david.murray
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25840] Allow `False` to be passed to `filter`

2015-12-11 Thread Emanuel Barry

Emanuel Barry added the comment:

Do you mean like 'filter(None, lst)' does?

--
nosy: +ebarry

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25840] Allow `False` to be passed to `filter`

2015-12-11 Thread leewz

leewz added the comment:

ebarry, note that `filter(None, lst)` is equivalent to `filter(bool, lst)`, 
which is the opposite of `filterfalse(None, lst)`. (Though `filter(True, lst) 
== filter(bool, lst)` would be a parallel.)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com