cheap-repr
Better version of repr/reprlib for short, cheap string representations.
What it is and what it does
cheap_repr is a drop-in replacement for Python's built-in repr() that produces shorter, faster string representations of objects. It truncates long outputs intelligently, handles nesting depth limits, and suppresses expensive repr computations for classes that produce very long strings. The library comes with built-in handlers for common types like lists, dicts, and strings, and lets you register custom repr functions for your own classes.
You use it by calling cheap_repr(obj) instead of repr(obj). It respects a configurable suppression threshold (default 300 characters) and max nesting level (default 3), making it useful in debugging, logging, and REPL contexts where repr output can become unwieldy. You can tune behavior globally or per-function, and it catches exceptions in repr functions to prevent crashes.
Use it for:
- Debug logging of large data structures without truncating manually or waiting for slow repr computations
- REPL and interactive environments where long object representations clutter the output
- Custom repr registration for domain-specific types to control how they appear in logs and error messages
- Preventing performance issues in exception handlers or debuggers that call repr on many objects
- Nested data structure inspection where you want to limit depth and width of the output
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides short, fast, configurable string representations as an alternative to the standard library's repr, with built-in handling for common types and an API for registering custom repr functions.
Yes, if you work with large or deeply nested data structures and want faster, more readable repr output. The package is stable, has no dependencies, and carries no security vulnerabilities. Maintenance is dormant but the code is mature; install it if your use case matches, but don't expect active feature development.
Install
cheap-repr on PyPI
pip
pip install cheap-repruv
uv add cheap-reprpoetry
poetry add cheap-reprInstalling cheap-repr
Before you install
Low install friction with no runtime dependencies. Maintenance is dormant—last release was 2024-08-10 and no commits since then—but the repository remains active and the package is stable enough for production use if your needs haven't changed.
License in practice
MIT license is permissive; you can use this package freely in commercial and private projects with minimal restrictions.
Quickstart
from cheap_repr import cheap_repr
result = cheap_repr(list(range(100)))
print(result) # '[0, 1, 2, ..., 97, 98, 99]'
Verify before relying
- Whether pandas DataFrame and Series repr customization (max_rows, max_cols) works with current pandas versions
- Performance improvement magnitude compared to reprlib on large nested structures
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 734 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 268,099/month — #8,283 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cheap_repr-0.5.2-py2.py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
renewGenerates reproducible string representations…
permissive · top 15,000 on PyPI
pprintpppprintpp is a drop-in replacement for Python's…
permissive · top 5,000 on PyPI
sqlalchemy-reprAdds automatic, human-readable repr() output to…
unclear · top 15,000 on PyPI
jsonconversionConverts arbitrary Python objects to JSON…
permissive · top 5,000 on PyPI
ptpythonptpython is an advanced interactive Python…
permissive · top 5,000 on PyPI
fastnumbersConverts strings and other inputs to numbers…
permissive · top 15,000 on PyPI
objectoryProvides dynamic object factory implementations…
permissive · top 15,000 on PyPI
shortuuidGenerates concise, URL-safe unique identifiers…
permissive · top 1,000 on PyPI
pampyPampy provides pattern matching for Python,…
permissive · top 15,000 on PyPI
eereprAdds interactive HTML representations to Earth…
permissive · top 15,000 on PyPI