For any & every

What do you mean? I’m not counting anything.

It’s no syntax, but it will be special cased. Calling it on a regular generator still works.

I don’t like that either, but it’s difficult to do this without adding new syntax or keywords.

Sounds interesting, sadly that probably requires a __future__ import, which can’t be used in older code:

    from __future__ import some_awesome_new_feature
# SyntaxError: from __future__ imports must occur at the beginning of the file

I take back half of what I said.

How would that work?

My mistake, I took your Example 3 for something other than it is. By the way, it will always evaluate to False. Something more realistic would be better in its place.

Is there no other way to achieve optimization your are aiming at without new syntax introduction?


result = (value < 0 for values in values_list if len(values) > 5
                    for value in values).any()

Again, it’s no new syntax, just a method on a literal. I don’t see a way for them to even match the performance of a for loop if they’re builtins.