8000 timeit: remove --clock and --time options · python/cpython@3d7feb9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d7feb9

Browse files
committed
timeit: remove --clock and --time options
Issue #28240: timeit: remove -c/--clock and -t/--time command line options which were deprecated since Python 3.3.
1 parent 1b90115 commit 3d7feb9

File tree

4 files changed

+5
-28
lines changed

4 files changed

+5
-28
lines changed

Doc/library/timeit.rst

+1-9
Original file line numberDiff line numberDiff line change
@@ -197,7 +1 10000 97,7 @@ Command-Line Interface
197197

198198
When called as a program from the command line, the following form is used::
199199

200-
python -m timeit [-n N] [-r N] [-u U] [-s S] [-t] [-c] [-h] [statement ...]
200+
python -m timeit [-n N] [-r N] [-u U] [-s S] [-h] [statement ...]
201201

202202
Where the following options are understood:
203203

@@ -222,20 +222,12 @@ Where the following options are understood:
222222

223223
.. versionadded:: 3.3
224224

225-
.. cmdoption:: -t, --time
226-
227-
use :func:`time.time` (deprecated)
228-
229225
.. cmdoption:: -u, --unit=U
230226

231227
specify a time unit for timer output; can select usec, msec, or sec
232228

233229
.. versionadded:: 3.5
234230

235-
.. cmdoption:: -c, --clock
236-
237-
use :func:`time.clock` (deprecated)
238-
239231
.. cmdoption:: -v, --verbose
240232

241233
print raw timing results; repeat for more digits precision

Lib/test/test_timeit.py

-12
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,6 @@ def test_main_help(self):
293293
# the help text, but since it's there, check for it.
294294
self.assertEqual(s, timeit.__doc__ + ' ')
295295

296-
def test_main_using_time(self):
297-
fake_timer = FakeTimer()
298-
s = self.run_main(switches=['-t'], timer=fake_timer)
299-
self.assertEqual(s, self.MAIN_DEFAULT_OUTPUT)
300-
self.assertIs(fake_timer.saved_timer, time.time)
301-
302-
def test_main_using_clock(self):
303-
fake_timer = FakeTimer()
304-
s = self.run_main(switches=['-c'], timer=fake_timer)
305-
self.assertEqual(s, self.MAIN_DEFAULT_OUTPUT)
306-
self.assertIs(fake_timer.saved_timer, time.clock)
307-
308296
def test_main_verbose(self):
309297
s = self.run_main(switches=['-v'])
310298
self.assertEqual(s, dedent("""\

Lib/timeit.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
Library usage: see the Timer class.
1010
1111
Command line usage:
12-
python timeit.py [-n N] [-r N] [-s S] [-t] [-c] [-p] [-h] [--] [statement]
12+
python timeit.py [-n N] [-r N] [-s S] [-p] [-h] [--] [statement]
1313
1414
Options:
1515
-n/--number N: how many times to execute 'statement' (default: see below)
1616
-r/--repeat N: how many times to repeat the timer (default 3)
1717
-s/--setup S: statement to be executed once initially (default 'pass').
1818
Execution time of this setup statement is NOT timed.
1919
-p/--process: use time.process_time() (default is time.perf_counter())
20-
-t/--time: use time.time() (deprecated)
21-
-c/--clock: use time.clock() (deprecated)
2220
-v/--verbose: print raw timing results; repeat for more digits precision
2321
-u/--unit: set the output time unit (usec, msec, or sec)
2422
-h/--help: print this usage message and exit
@@ -291,10 +289,6 @@ def main(args=None, *, _wrap_timer=None):
291289
repeat = int(a)
292290
if repeat <= 0:
293291
repeat = 1
294-
if o in ("-t", "--time"):
295-
timer = time.time
296-
if o in ("-c", "--clock"):
297-
timer = time.clock
298292
if o in ("-p", "--process"):
299293
timer = time.process_time
300294
if o in ("-v", "--verbose"):

Misc/NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ Core and Builtins
8888
Library
8989
-------
9090

91+
- Issue #28240: timeit: remove ``-c/--clock`` and ``-t/--time`` command line
92+
options which were deprecated since Python 3.3.
93+
9194
- Issue #28240: timeit now repeats the benchmarks 5 times instead of only 3
9295
to make benchmarks more reliable.
9396

0 commit comments

Comments
 (0)
0