Skip to main content

A performance-focused reimplementation of Textual's DataTable widget, with a pluggable data storage backend.

Project description

textual-fastdatatable

A performance-focused reimplementation of Textual's DataTable widget, with a pluggable data storage backend.

Textual's built-in DataTable widget is beautiful and powerful, but it can be slow to load large datasets.

Here are some benchmarks on my relatively weak laptop. For each benchmark, we initialize a Textual App that loads a 6-column dataset from a parquet file and mounts a data table:

Records Built-in DataTable FastDataTable
100 0.21s 0.12s
1000 0.50s 0.12s
10000 3.78s 0.12s
100000 37.84s 0.14s
538121 231.17s 0.18s

NB: FastDataTable currently does not support rows with a height of more than one line. See below for more limitations, relative to the built-in DataTable.

Installation

pip install textual-fastdatatable

Usage

If you already have data in Apache Arrow or another common table format:

from textual_fastdatatable import DataTable
data_table = DataTable(data = my_data)

The currently supported types are:

AutoBackendType = Union[
    pa.Table,
    pa.RecordBatch,
    Path, # to parquet only
    str, # path to parquet only
    Sequence[Iterable[Any]],
    Mapping[str, Sequence[Any]],
]

To override the column labels and widths supplied by the backend:

from textual_fastdatatable import DataTable
data_table = DataTable(data = my_data, column_labels=["Supports", "[red]Console[/]", "Markup!"], column_widths=[10, 5, None])

You can also pass in a backend manually (if you want more control or want to plug in your own).

from textual_fastdatatable import ArrowBackend, DataTable, create_backend
backend = create_backend(my_data)
backend = ArrowBackend(my_arrow_table)
# from python dictionary in the form key: col_values
backend = ArrowBackend.from_pydict(
    {
        "col one": [1, 2, 3 ,4],
        "col two": ["a", "b", "c", "d"],
    }
)
# from a list of tuples or another sequence of iterables
backend = ArrowBackend.from_records(
    [
        ("col one", "col two"),
        (1, "a"),
        (2, "b"),
        (3, "c"),
        (4, "d"),
    ]
)
# from a path to a Parquet file:
backend = ArrowBackend.from_parquet("path/to/file.parquet")

Limitations and Caveats

The DataTable does not currently support rows with a height of more than one line. Only the first line of each row will be displayed.

The ArrowBackend is optimized to be fast for large, immutable datasets. Mutating the data, especially adding or removing rows, may be slow.

The ArrowBackend cannot be initialized without data, however, the DataTable can (either with or without column_labels).

The ArrowBackend cannot store arbitrary Python objects or Rich Renderables as values. It may widen types to strings unnecessarily.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textual_fastdatatable-0.1.1.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

textual_fastdatatable-0.1.1-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file textual_fastdatatable-0.1.1.tar.gz.

File metadata

  • Download URL: textual_fastdatatable-0.1.1.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1012-azure

File hashes

Hashes for textual_fastdatatable-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8f7890266c4ecc0ecbf540b4cf863b0238168c94a68132588b70cf48d5db5c89
MD5 5f74633ce070d4670e2015a0b9224ba0
BLAKE2b-256 a030aefba8a9f11d6960c8e014f85b62ae09193cf01288adebdd379cd0c72186

See more details on using hashes here.

File details

Details for the file textual_fastdatatable-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for textual_fastdatatable-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d329bc55474308c2e7838cac10de94f3c0c6ece81bd78c3dd12546c942eb04d5
MD5 b3ea813e5ad60faa9beaf407478665ef
BLAKE2b-256 76355f6eba1423528c1ee3fff783d55d88b13d7c42bca28698976175230263e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page