shiny-py-optimize

Solid

Diagnose and fix performance problems in Shiny for Python apps — slow startup, sluggish interactions, blocking operations, and apps that struggle beyond a handful of concurrent users. Use when a Shiny for Python app is slow, hangs, recomputes too much, times out, or must support more users; when the user asks to "speed up", "optimize", or "make faster" a Python Shiny app; or when preparing a prototyped app for real-world traffic.

Data & Documents 568 stars 60 forks Updated 5 days ago MIT

Install

View on GitHub

Quality Score: 92/100

Stars 20%
92
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Optimizing Shiny for Python App Performance Make an existing Shiny for Python app faster without changing what it does. The typical user has an app that worked fine for one or two developers and is now too slow or must support more users. Keep all app logic intact; prefer code changes over deployment tuning; resist rewrites. Order of preference for every fix: 1. **Eliminate** work that isn't needed (don't compute outputs nobody is looking at; don't compute with inputs that aren't ready). 2. **Reuse** work that repeats (shared `@reactive.calc`, module-level caches). 3. **Accelerate** unavoidable work (faster data formats, polars, push-down). 4. **Relocate** work that blocks (`@reactive.extended_task`) — last resort; it buys concurrency, not raw speed. One fact drives most Python-specific advice: **every session in a process shares one asyncio event loop.** A *synchronous* blocking call in any reactive function freezes every session in the process. What a slow `async def` reactive blocks depends on the shiny version (check with `python -c "import shiny; print(shiny.__version__)"`): - **shiny < 1.9.0:** reactive functions run serially across the whole process, so a slow `async` reactive also freezes every session. - **shiny ≥ 1.9.0:** effects run concurrently, so a slow `async` reactive holds only *its own* session (no input updates, no outputs until it finishes); other sessions keep running. Either way, `async`/`await` alone never keeps the *same* session re...

Details

Author
posit-dev
Repository
posit-dev/skills
Created
12 months ago
Last Updated
5 days ago
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category