Skip to content

Repository files navigation

Printable

CLI and functions help for printing tabular data.

Install

pip3 install printable

Rendering Engines

Two engines render tables: python (pure Python) and column (a ctypes binding of the compiled util-linux column command). By default (auto), the column engine is used when no --grid is set, and falls back to the python engine if the shared library is missing; grid styles always use the python engine. Select explicitly with -e python|column|auto.

Width calculation uses the native library when available and falls back to pure Python otherwise. The native width path has an ASCII fast path and batches all cells into one C call. The current benchmark uses 5000×6 mixed zh-en rows on an Apple M4:

engine input median (ms) speedup
Python rows 80.32 1.00x
Python + C width rows 28.37 2.83x
Python column str 14.62 5.49x
Python column bytes 14.51 5.53x
Go column []byte 14.10 5.70x

Python uses two warmups and ten repetitions; Go uses go test -bench with three runs. The standalone Python C-width call is 2.45 ms for the same 5000×6 cells; Go BenchmarkWidthsOf is 1.13 ms/op, 651–706 MB/s, with 17 allocations. The Go render benchmark reports about 811 KB and 5 allocations per render. The str/bytes difference is the Python UTF-8 input conversion cost; with pre-encoded input, both Go and Python spend most of the time in the shared C implementation.

Usage Example

from printable import readable

print(readable(list_of_dict, grid='full'))

See more in samples/output.log.

About

CLI and functions help for printing tabular data.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages