-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Allow False
to be passed to filter
#70027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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.) |
Do you mean like 'filter(None, lst)' does? |
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 |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: