|
|
|
|
|
by rickboyce
1023 days ago
|
|
I think the analysis is really interesting, but I suspect it’s quite possible that this behaviour is just a result of optimising the implementation than GVR taking sides in a 2,500 year old philosophical debate. Both implementations of all() and any() short-circuit by returning as soon as a fasly element in all or a truthy element in any is iterated over. The origin of these two functions seems to be this post: https://www.artima.com/forums/flat.jsp?forum=106&thread=9819... Guido makes no comment on empty iterables, but does comment on the final implementation needing to be efficient. It’s possible this behaviour is just the engineering trade off made for a slightly more efficient implementation. The initial commit of these two functions - https://github.com/python/cpython/commit/96229b191814556622b... - is exactly as Guido’s suggestion, but does include a test case for empty iterables for both functions so we know it wasn’t overlooked. |
|