
On Wed, 13 May 2020 19:27:57 -0700 Ethan Furman <ethan@stoneleaf.us> wrote:
On 05/13/2020 06:04 AM, Antoine Pitrou wrote:
On Tue, 12 May 2020 11:36:38 -0700 Ethan Furman wrote:
Also, if a flag is used, won't that slow down every call to zip even when the flag is False?
Why would it? Is that based on a rational analysis of how argument parsing works?
Not the call itself, but the running of zip. Absent some clever programming it seems to me that there are two choices if we have a flag:
- have two independent branches (basically `zip` and a `zip_strict` functions inside `zip` itself) and have the flag select the branch; or
- have one branch which has extra logic that checks for at least one StopIteration and at least one item in each iteration to see if it should raise.
And how much do you think that costs, compared to the overall cost of running the entire zip() function, including consumption of yielded results by the calling frame?