From 06df2b1d220867a8c85f28bf0bb1951cdc08ee8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 14 Feb 2026 21:18:02 +0200 Subject: [PATCH 1/2] docs: improve timeit autorange description It not only determines but actually runs timeit a number of times. Also be more concise; the original form said basically the same thing twice. --- Doc/library/timeit.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst index bc12061a2aeb2d..fc5e2b13922396 100644 --- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -145,13 +145,12 @@ The module defines three convenience functions and a public class: .. method:: Timer.autorange(callback=None) - Automatically determine how many times to call :meth:`.timeit`. + Call :meth:`.timeit` automatically determined number of times. This is a convenience function that calls :meth:`.timeit` repeatedly - so that the total time >= 0.2 second, returning the eventual - (number of loops, time taken for that number of loops). It calls - :meth:`.timeit` with increasing numbers from the sequence 1, 2, 5, - 10, 20, 50, ... until the time taken is at least 0.2 seconds. + with increasing numbers from the sequence 1, 2, 5, 10, 20, 50, ... + until the time taken is at least 0.2 seconds, returning the eventual + (number of loops, time taken for that number of loops). If *callback* is given and is not ``None``, it will be called after each trial with two arguments: ``callback(number, time_taken)``. From 787977f53c319d84cf62207936a7d4087e5e0e66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 20 Feb 2026 21:16:15 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: bkap123 <97006829+bkap123@users.noreply.github.com> --- Doc/library/timeit.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst index fc5e2b13922396..a686050a3589ae 100644 --- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -145,10 +145,10 @@ The module defines three convenience functions and a public class: .. method:: Timer.autorange(callback=None) - Call :meth:`.timeit` automatically determined number of times. + Call :meth:`.timeit` an automatically determined number of times. - This is a convenience function that calls :meth:`.timeit` repeatedly - with increasing numbers from the sequence 1, 2, 5, 10, 20, 50, ... + This is a convenience function that repeatedly calls :meth:`.timeit` + with an increasing amount of iterations from the sequence 1, 2, 5, 10, 20, 50, ... until the time taken is at least 0.2 seconds, returning the eventual (number of loops, time taken for that number of loops).