Feature Request: Add a Generic SpeedColumn to progress.py
Summary
Add a new SpeedColumn progress column that displays speed for arbitrary units (iterations, rows, files, etc.), complementing the existing TransferSpeedColumn which is specialized for byte transfer speeds.
Problem / Motivation
Currently, TransferSpeedColumn displays transfer speed in bytes (e.g., 3.2 MB/s), which is ideal for file downloads or data transfers. However, many progress use cases track non-byte quantities:
- Rows processed in a CSV or database
- Web requests completed
- Images or items processed
- API calls made
- Generic iterations over any sequence
There is no standalone column in rich/progress.py that can display speed for these cases. While TaskProgressColumn has a show_speed option that displays iterations per second when total is unknown, it is embedded within the percentage column and uses a fixed "it/s" unit with scientific notation (e.g., 5.0×10³ it/s). Users cannot easily show a dedicated speed column with a custom unit like "rows/s" or "files/s".
Proposed Solution
Add a new ProgressColumn class called SpeedColumn in rich/progress.py with the following behavior:
API
SpeedColumn(unit: str = "it", table_column: Optional[Column] = None)
unit: A short string describing the unit (e.g., "it", "rows", "files", "req"). Default is "it" (short for "iterations").
Display Format
| Condition |
Output Example |
task.speed is None |
? it/s (or ? {unit}/s) |
| Speed < 1000 |
42.5 it/s, 7.3 rows/s |
| Speed ≥ 1000 |
1.2k it/s, 15.3k rows/s |
- Format:
"{value} {unit}/s" for normal speeds
- For speeds ≥ 1000: use
"k" suffix to keep output compact (e.g., 1.2k it/s instead of 1200.0 it/s)
Example Usage
from rich.progress import Progress, BarColumn, TextColumn, SpeedColumn, TimeRemainingColumn
# Processing rows from a file
progress = Progress(
TextColumn("[progress.description]{task.description}"),
BarColumn(),
TextColumn("{task.completed}/{task.total}"),
SpeedColumn(unit="rows"),
TimeRemainingColumn(),
)
with progress:
task_id = progress.add_task("Processing CSV", total=10000)
for row in csv_reader:
process(row)
progress.advance(task_id)
# Web requests
progress = Progress(
TextColumn("{task.description}"),
BarColumn(),
SpeedColumn(unit="req"),
TimeRemainingColumn(),
)
Implementation Notes
- The column should read
task.finished_speed or task.speed (consistent with TransferSpeedColumn and TaskProgressColumn.render_speed)
- Use the
progress.data.speed style (or equivalent) for consistency with TransferSpeedColumn
- Consider using
filesize.pick_unit_and_suffix or similar logic for the "k" formatting, or implement a simple formatter (e.g., f"{speed/1000:.1f}k" when speed >= 1000)
Testing
Add tests in tests/test_progress.py covering:
- Speed is
None → "? it/s" (or "? {unit}/s" for custom unit)
- Small speed (e.g., 42.5) →
"42.5 it/s"
- Large speed (≥ 1000, e.g., 1234.5) →
"1.2k it/s" (or equivalent)
- Custom unit (e.g.,
unit="rows") → "7.3 rows/s", "? rows/s"
Checklist for Contributors
References
TransferSpeedColumn (lines 694–704 in rich/progress.py) - byte-specific speed column
TaskProgressColumn.render_speed (lines 531–544) - iterations/s with scientific notation
- Progress documentation
- CONTRIBUTING.md
Feature Request: Add a Generic SpeedColumn to progress.py
Summary
Add a new
SpeedColumnprogress column that displays speed for arbitrary units (iterations, rows, files, etc.), complementing the existingTransferSpeedColumnwhich is specialized for byte transfer speeds.Problem / Motivation
Currently,
TransferSpeedColumndisplays transfer speed in bytes (e.g.,3.2 MB/s), which is ideal for file downloads or data transfers. However, many progress use cases track non-byte quantities:There is no standalone column in
rich/progress.pythat can display speed for these cases. WhileTaskProgressColumnhas ashow_speedoption that displays iterations per second whentotalis unknown, it is embedded within the percentage column and uses a fixed "it/s" unit with scientific notation (e.g.,5.0×10³ it/s). Users cannot easily show a dedicated speed column with a custom unit like "rows/s" or "files/s".Proposed Solution
Add a new
ProgressColumnclass calledSpeedColumninrich/progress.pywith the following behavior:API
unit: A short string describing the unit (e.g.,"it","rows","files","req"). Default is"it"(short for "iterations").Display Format
task.speedisNone? it/s(or? {unit}/s)42.5 it/s,7.3 rows/s1.2k it/s,15.3k rows/s"{value} {unit}/s"for normal speeds"k"suffix to keep output compact (e.g.,1.2k it/sinstead of1200.0 it/s)Example Usage
Implementation Notes
task.finished_speed or task.speed(consistent withTransferSpeedColumnandTaskProgressColumn.render_speed)progress.data.speedstyle (or equivalent) for consistency withTransferSpeedColumnfilesize.pick_unit_and_suffixor similar logic for the "k" formatting, or implement a simple formatter (e.g.,f"{speed/1000:.1f}k"whenspeed >= 1000)Testing
Add tests in
tests/test_progress.pycovering:None→"? it/s"(or"? {unit}/s"for custom unit)"42.5 it/s""1.2k it/s"(or equivalent)unit="rows") →"7.3 rows/s","? rows/s"Checklist for Contributors
SpeedColumnclass torich/progress.pySpeedColumninrich/progress.py(if there is an__all__or public API)tests/test_progress.pydocs/source/progress.rstto document the new columnCHANGELOG.md(when submitting PR)References
TransferSpeedColumn(lines 694–704 inrich/progress.py) - byte-specific speed columnTaskProgressColumn.render_speed(lines 531–544) - iterations/s with scientific notation