Textual Speedups

0.2.1 · active · verified Fri Apr 10

textual-speedups provides optional Rust-based performance enhancements for the Textual TUI framework. It implements core Textual classes like `Offset`, `Size`, `Region`, and `Spacing` in Rust to potentially make Textual applications faster. Currently at version 0.2.1 (released November 28, 2025), the library is experimental and its development follows the Textual ecosystem, with releases occurring a few times a year.

Warnings

Install

Imports

Quickstart

To use textual-speedups, simply install it into the same Python environment as your Textual application. Textual will automatically detect and integrate the speedups. The example above is a standard Textual clock app; installing textual-speedups would potentially optimize its underlying Textual operations without requiring any code changes to the app itself.

import os
from datetime import datetime
from textual.app import App, ComposeResult
from textual.widgets import Digits

# Set TEXTUAL_SPEEDUPS=0 in your environment to disable speedups for comparison:
# os.environ['TEXTUAL_SPEEDUPS'] = '0'

class ClockApp(App):
    CSS = '''
    Screen {
        align: center middle;
    }
    Digits {
        width: auto;
    }
    '''
    def compose(self) -> ComposeResult:
        yield Digits('')

    def on_ready(self) -> None:
        self.update_clock()
        # The interval timer and widget updates are areas where
        # textual-speedups might offer performance benefits.
        self.set_interval(1, self.update_clock)

    def update_clock(self) -> None:
        clock = datetime.now().time()
        self.query_one(Digits).update(f'{clock:%T}')

if __name__ == '__main__':
    app = ClockApp()
    app.run()

view raw JSON →