[Python-Dev] Re: PEP 618: Add Optional Length-Checking To zip

2020年5月14日 05:48:25 -0700

On 2020年5月13日 19:27:57 -0700
Ethan Furman <[email protected]> wrote:
> On 05/13/2020 06:04 AM, Antoine Pitrou wrote:
> > On 2020年5月12日 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?
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/LDUDSLWQDZNNMSRKKNMOEC7NSVTUEKCC/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to