FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-146609: Add colour to `timeit` CLI output by hugovk · Pull Request #146610 · python/cpython · GitHub

Repository navigation

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

Merged
hugovk merged 9 commits into
python:mainfrom
hugovk:3.15-timeit-colour
Apr 8, 2026
Merged

hugovk merged 9 commits into
python:mainfrom
hugovk:3.15-timeit-colour

Conversation

hugovk commented Mar 29, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

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))"

With a warning:

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

As usual, environment variables can control colour output.


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

Comment thread Lib/test/test_timeit.py Outdated
Comment thread Lib/timeit.py
Comment thread Lib/timeit.py Outdated
Comment thread Lib/test/test_timeit.py

ambv commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

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 commented Apr 7, 2026

Copy link
Copy Markdown
Member Author

Like this?

ambv commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Yes, that looks better to me!

hugovk merged commit 8687b9d into python:main Apr 8, 2026
60 checks passed
hugovk deleted the 3.15-timeit-colour branch April 8, 2026 13:18

hugovk commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

Thanks both for the reviews!

This comment was marked as off-topic.

ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
Co-authored-by: Stan Ulbrych <stan@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL