cpython: 975df4c13db6 (original) (raw)
Mercurial > cpython
changeset 104539:975df4c13db6
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. [#28240]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Tue, 18 Oct 2016 17🔞21 +0200 |
parents | 2dafb2f3e7ff |
children | 4d611957732b |
files | Doc/library/timeit.rst Lib/test/test_timeit.py Lib/timeit.py Misc/NEWS |
diffstat | 4 files changed, 5 insertions(+), 28 deletions(-)[+] [-] Doc/library/timeit.rst 10 Lib/test/test_timeit.py 12 Lib/timeit.py 8 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -197,7 +197,7 @@ Command-Line Interface When called as a program from the command line, the following form is used::
Where the following options are understood: @@ -222,20 +222,12 @@ Where the following options are understo .. versionadded:: 3.3 -.. cmdoption:: -t, --time -
.. cmdoption:: -u, --unit=U specify a time unit for timer output; can select usec, msec, or sec .. versionadded:: 3.5 -.. cmdoption:: -c, --clock -
.. cmdoption:: -v, --verbose print raw timing results; repeat for more digits precision
--- a/Lib/test/test_timeit.py +++ b/Lib/test/test_timeit.py @@ -293,18 +293,6 @@ class TestTimeit(unittest.TestCase): # the help text, but since it's there, check for it. self.assertEqual(s, timeit.doc + ' ')
- def test_main_using_time(self):
fake_timer = FakeTimer()[](#l2.8)
s = self.run_main(switches=['-t'], timer=fake_timer)[](#l2.9)
self.assertEqual(s, self.MAIN_DEFAULT_OUTPUT)[](#l2.10)
self.assertIs(fake_timer.saved_timer, time.time)[](#l2.11)
- def test_main_using_clock(self):
fake_timer = FakeTimer()[](#l2.14)
s = self.run_main(switches=['-c'], timer=fake_timer)[](#l2.15)
self.assertEqual(s, self.MAIN_DEFAULT_OUTPUT)[](#l2.16)
self.assertIs(fake_timer.saved_timer, time.clock)[](#l2.17)
- def test_main_verbose(self): s = self.run_main(switches=['-v']) self.assertEqual(s, dedent("""[](#l2.21)
--- a/Lib/timeit.py +++ b/Lib/timeit.py @@ -9,7 +9,7 @@ the Python Cookbook, published by O'Reil Library usage: see the Timer class. Command line usage:
Options: -n/--number N: how many times to execute 'statement' (default: see below) @@ -17,8 +17,6 @@ Options: -s/--setup S: statement to be executed once initially (default 'pass'). Execution time of this setup statement is NOT timed. -p/--process: use time.process_time() (default is time.perf_counter())
- -t/--time: use time.time() (deprecated)
- -c/--clock: use time.clock() (deprecated) -v/--verbose: print raw timing results; repeat for more digits precision -u/--unit: set the output time unit (usec, msec, or sec) -h/--help: print this usage message and exit @@ -291,10 +289,6 @@ def main(args=None, *, _wrap_timer=None) repeat = int(a) if repeat <= 0: repeat = 1
if o in ("-t", "--time"):[](#l3.25)
timer = time.time[](#l3.26)
if o in ("-c", "--clock"):[](#l3.27)
timer = time.clock[](#l3.28) if o in ("-p", "--process"):[](#l3.29) timer = time.process_time[](#l3.30) if o in ("-v", "--verbose"):[](#l3.31)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -88,6 +88,9 @@ Core and Builtins
Library
-------
+- Issue #28240: timeit: remove -c/--clock
and -t/--time
command line