Skip to content

gh-146609: Add colour to timeit CLI output#146610

Open
hugovk wants to merge 9 commits intopython:mainfrom
hugovk:3.15-timeit-colour
Open

gh-146609: Add colour to timeit CLI output#146610
hugovk wants to merge 9 commits intopython:mainfrom
hugovk:3.15-timeit-colour

Conversation

@hugovk
Copy link
Copy Markdown
Member

@hugovk hugovk commented Mar 29, 2026

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 "import time, random; time.sleep(random.random() * 0.9)"
image

As usual, environment variables can control colour output.


📚 Documentation preview 📚: https://cpython-previews--146610.org.readthedocs.build/

@ambv
Copy link
Copy Markdown
Contributor

ambv commented Apr 7, 2026

Nitpick: I would segment this differently. The fact that the entire line after "raw times:" is just cyan is a wasted opportunity. Would make sense to me to make the commas delimiting the values be colored the same way as the arrows.

@hugovk
Copy link
Copy Markdown
Member Author

hugovk commented Apr 7, 2026

Like this?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants