[Python-ideas] Adding an optional function argument to all() and any() builtins
masklinn at masklinn.net
Sun Nov 21 22:35:41 CET 2010
On 2010-11-21, at 21:43 , Alexander Belopolsky wrote:
> On Sun, Nov 21, 2010 at 3:20 PM, Masklinn <masklinn at masklinn.net> wrote:
>> On 2010-11-21, at 21:11 , MRAB wrote:
>>> if any(mytestfunction(i) for i in mylist):
>> is not an improvement over `if any(map(mytestfunction, mylist))` or `if any(imap(mytestfunction, mylist))`
> In 2.7, both MRAB's generator expression solution and your imap() are
> improvements over map() because they don't create a temporary list.
Which doesn't actually mean it's an improvement, gencomps are not always faster than map when the transformer is a function in all cases.
More information about the Python-ideas