SIGN IN SIGN UP

gh-116159: argparse: performance improvement parsing large number of options (#116162)

When parsing positional vs optional arguments, the use of min with a
list comprehension inside of a loop results in quadratic time based
on the number of optional arguments given. When combined with use of
prefix based argument files and a large number of optional flags, this
can result in extremely slow parsing behavior.

This replaces the min call with a simple loop with a short circuit to
break at the next optional argument.

Co-authored-by: Zsolt Dollenstein <zsol.zsol@gmail.com>
A
Amethyst Reese committed
4a630980328b67f0aba6a04c3950aa9dbd532895
Parent: 7b47943
Committed by GitHub <noreply@github.com> on 3/1/2024, 10:52:53 AM