3 ms·
But "any" short-circuits: that smells the same as a list comprehension for side effects. The beauty of Python is that the one, obvious way to do something is u
by adamtj 14y ago
But "any" short-circuits: that smells the same as a list comprehension for side effects.
The beauty of Python is that the one, obvious way to do something is usually the right way. When you try to force something like this, you either run into silly bugs like "any" short-circuiting, or you waste your limited brainpower trying to avoid them. You're usually better off looking for algorithmic or architectural optimizations for speed, or refactoring for readability.
- talaketu 14y ago"any" applied to a generator expression with side-effects is smelly because of the generator expression with side-effects, not because of the short-circuit. "any" applied to a pure generator expression expresses the algorithmic optimization known as short circuiting. Once you are at the point of considering execution time to be a side effect, the purity of any non-trivial expression vanishes.