itertools.ifilter Vs. filter Vs. list comprehensions

Your understanding is correct: the only difference is that ifilter returns an iterator, while using filter is like calling:

list(ifilter(...))

You may also be interested in what PEP 289 says about filter and ifilter:

List comprehensions greatly reduced the need for filter() and map(). Likewise, generator expressions are expected to minimize the need for itertools.ifilter() and itertools.imap(). […]

Also note that ifilter became filter in Python-3 (hence removed from itertools).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)