{"id":2807,"library":"textual-speedups","title":"Textual Speedups","description":"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.","status":"active","version":"0.2.1","language":"en","source_language":"en","source_url":"https://github.com/willmcgugan/textual-speedups","tags":["textual","performance","rust","tui","gui","speedups","experimental"],"install":[{"cmd":"pip install textual-speedups","lang":"bash","label":"Install textual-speedups"}],"dependencies":[{"reason":"textual-speedups provides optional performance enhancements for the Textual TUI framework and requires Textual to be installed in the same environment to function. It is not a direct PyPI dependency of textual-speedups, but a peer dependency.","package":"textual","optional":false}],"imports":[{"note":"Users continue to import geometry classes (e.g., Offset, Size) directly from the 'textual.geometry' module; 'textual-speedups' transparently replaces their Python implementations with Rust versions.","symbol":"Automatic Integration","correct":"No direct imports from 'textual_speedups' are typically needed. Once installed, Textual automatically detects and utilizes the Rust speedups."}],"quickstart":{"code":"import os\nfrom datetime import datetime\nfrom textual.app import App, ComposeResult\nfrom textual.widgets import Digits\n\n# Set TEXTUAL_SPEEDUPS=0 in your environment to disable speedups for comparison:\n# os.environ['TEXTUAL_SPEEDUPS'] = '0'\n\nclass ClockApp(App):\n    CSS = '''\n    Screen {\n        align: center middle;\n    }\n    Digits {\n        width: auto;\n    }\n    '''\n    def compose(self) -> ComposeResult:\n        yield Digits('')\n\n    def on_ready(self) -> None:\n        self.update_clock()\n        # The interval timer and widget updates are areas where\n        # textual-speedups might offer performance benefits.\n        self.set_interval(1, self.update_clock)\n\n    def update_clock(self) -> None:\n        clock = datetime.now().time()\n        self.query_one(Digits).update(f'{clock:%T}')\n\nif __name__ == '__main__':\n    app = ClockApp()\n    app.run()","lang":"python","description":"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."},"warnings":[{"fix":"Use for development and testing purposes only. Monitor the official Textual and textual-speedups repositories for updates on stability and production readiness.","message":"Textual-speedups is currently experimental and should not be used in production environments. It is under active development and may not be stable.","severity":"gotcha","affected_versions":"All versions (0.2.1 and earlier)"},{"fix":"Thoroughly test your Textual application with textual-speedups enabled. Report any issues to the project's GitHub repository. If unexpected behavior occurs, disable the speedups as a first troubleshooting step.","message":"There is a possibility of encountering edge cases, crashes, or subtle behavioral differences when using textual-speedups due to its experimental nature.","severity":"gotcha","affected_versions":"All versions (0.2.1 and earlier)"},{"fix":"Benchmarking your specific application is recommended to determine if textual-speedups provides a measurable improvement for your use case. Do not expect universal, dramatic speedups across all Textual apps.","message":"For simpler Textual applications, the performance benefits from textual-speedups might not be noticeable. The speedups primarily target internal geometry and layout calculations, which may only significantly impact complex UIs.","severity":"gotcha","affected_versions":"All versions (0.2.1 and earlier)"},{"fix":"Set the environment variable `TEXTUAL_SPEEDUPS=0` before running your Textual application. Example: `TEXTUAL_SPEEDUPS=0 python -m textual` or `os.environ['TEXTUAL_SPEEDUPS'] = '0'` within Python before app initialization.","message":"To temporarily or permanently disable textual-speedups, an environment variable must be set. This is useful for debugging or comparing performance with and without the speedups.","severity":"gotcha","affected_versions":"All versions (0.2.1 and earlier)"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}