skillfed

cheap-repr

Better version of repr/reprlib for short, cheap string representations.

cheap-repr v0.5.2 268.1K downloads/30d#8,283 on PyPI26
Permissive license MIT DORMANT released

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-repr

uv

uv add cheap-repr

poetry

poetry add cheap-repr

Installing 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

License :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

repr alternativestring representation truncationcustom repr registrationfast object reprrepr suppressionconfigurable repr outputreprlib replacement
debuggingrepr-customization

More Software Development packages