You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2015-12-11.15:45:34.289>created_at=<Date2015-12-11.15:02:00.929>labels= ['type-feature']
title='Allow `False` to be passed to `filter`'updated_at=<Date2015-12-11.19:54:59.059>user='https://github.com/leewz'
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.)
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 :)
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.)
Activity
leewz commentedon Dec 11, 2015
Meaning:
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.)
Vgr255 commentedon Dec 11, 2015
Do you mean like 'filter(None, lst)' does?
bitdancer commentedon Dec 11, 2015
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 :)
leewz commentedon Dec 11, 2015
ebarry, note that
filter(None, lst)is equivalent tofilter(bool, lst), which is the opposite offilterfalse(None, lst). (Thoughfilter(True, lst) == filter(bool, lst)would be a parallel.)