
On Wed, May 13, 2020 at 03:04:02PM +0200, Antoine Pitrou wrote:
On Tue, 12 May 2020 11:36:38 -0700 Ethan Furman <ethan@stoneleaf.us> 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?
I'm not an expert on Python's argument passing code in fine detail, but I'm reasonable sure that it takes longer to pass arguments by keyword than by position, and it takes time to fill in missing arguments with the default (they have to be read from the function defaults, which takes time) and these things don't happen for free. But I do think that's probably a spurious point based on a micro- or even nano-optimization. I don't think that the extra nanosecond or whatever it takes for zip to receive an extra argument, fill in the default if missing, and branch is significant. I don't think that `zip(*args, strict=flag)` is the wrong choice because it's a nanosecond slower, I think it's the wrong choice because it makes for a poorer API when there are better, more future-proof choices available. -- Steven