Skip to content

Add colour to timeit CLI output #146609

@hugovk

Description

@hugovk

Feature or enhancement

Proposal:

Taking inspiration from CLI tools such as hyperfine:

Image Image

Let's add colour to the CLI output of python -m timeit.

Standard and verbose:

./python.exe -m timeit "'-'.join(str(n) for n in range(100))"
./python.exe -m timeit --verbose "'-'.join(str(n) for n in range(100))"
image

With a warning:

./python.exe -m timeit --verbose "import time, random; time.sleep(random.random() * 0.5)"
image

As usual, environment variables can control colour output.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions