-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Documentation of timeit.Timer.timeit should mention that the return value depends on the timer #105052
Copy link
Copy link
Closed
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
Documentation
At the moment, it is as follows.
Lines 164 to 169 in cb4615f
| def timeit(self, number=default_number): | |
| """Time 'number' executions of the main statement. | |
| To be precise, this executes the setup statement once, and | |
| then returns the time it takes to execute the main statement | |
| a number of times, as a float measured in seconds. The |
The return value may not always be a float measured in seconds. If a different timer function is used:
timeit.timeit(timer=time.perf_counter_ns)
then it is an integer measured in nanoseconds.
Not entirely sure how to document it unambiguously, but perhaps it can be reworded to say something like: '… as a number measured in the time unit returned by the timer argument of the constructor (by default: a float measured in seconds).' Or similar?
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir