Date, Time and Localization Modules

time

Provides wall-clock time, monotonic clocks, time conversion and sleeping. Use monotonic() or perf_counter() to measure elapsed intervals instead of subtracting wall-clock timestamps, which may change due to clock adjustments. Clock resolution and formatting capabilities depend on the platform.

Formal Syntax & Structure

python syntaxpython
import time

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
import timestart = time.monotonic_ns()result = sum(range(100))finish = time.monotonic_ns()print(result)print(finish >= start)
Python Reference