@@ -227,6 +227,9 @@ def _make_parser():
227227argument in quotes and using leading spaces. Multiple -s options are
228228treated similarly.
229229
230+ Use "--" to separate command-line options from actual statements,
231+ or when a statement starts with '-'.
232+
230233If -n is not given, a suitable number of loops is calculated by trying
231234increasing numbers from the sequence 1, 2, 5, 10, 20, 50, ... until the
232235total time is at least 0.2 seconds.
@@ -265,13 +268,9 @@ def _make_parser():
265268 "-v" , "--verbose" , action = "count" , default = 0 ,
266269 help = "print raw timing results; repeat for more digits precision" ,
267270 )
268- # add a dummy option to document '--'
269- group .add_argument (
270- "--" , dest = "_" , action = "store_const" , const = None ,
271- help = "separate options from statement; "
272- "use when statement starts with -" ,
273- )
274- # use argparse.REMAINDER to ignore option-like argument found at the end
271+ # Use argparse.REMAINDER to ignore option-like argument found at the end.
272+ # If '--' is being specified as the "first" statement, it will be ignored
273+ # and used to separate the options from the list of statements.
275274 group .add_argument (
276275 "statement" , nargs = argparse .REMAINDER ,
277276 help = "statement to be timed (default: 'pass')" ,
@@ -300,6 +299,8 @@ def main(args=None, *, _wrap_timer=None):
300299 args = parser .parse_args (args )
301300
302301 setup = "\n " .join (args .setup ) or "pass"
302+ if args .statement and args .statement [0 ] == '--' :
303+ args .statement .pop (0 )
303304 stmt = "\n " .join (args .statement ) or "pass"
304305 timer = time .process_time if args .process else default_timer
305306 number = args .number # will be deduced if 0
0 commit comments