Skip to content
Skills Library
Programming · Building & coding

performant-python

/performant-python

Strategies for high-performance Python systems (FastAPI, Asyncio, UVloop, Memory Optimization). Use when: python, fastapi, performance, asyncio, uvloop, pydantic, scalability, profiling.

Repository
gabbe ↗
Licence
CC-BY-4.0
Last repository change
24.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
4
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 24.10.2026, without references to retired models or APIs.

Licence

CC-BY-4.0, otwarta.

What it does and when to use it

Strategies for high-performance Python systems (FastAPI, Asyncio, UVloop, Memory Optimization). Use when: python, fastapi, performance, asyncio, uvloop, pydantic, scalability, profiling.

Original author description

Strategies for high-performance Python systems (FastAPI, Asyncio, UVloop, Memory Optimization). Use when: python, fastapi, performance, asyncio, uvloop, pydantic, scalability, profiling.

How it works

  1. Goal
  2. Capabilities
  3. Steps
  4. Deliverables
  5. Security & Guardrails
Original SKILL.md headings · 56 lines, 454 words
SKILL.md preview
---
name: performant-python
description: "Strategies for high-performance Python systems (FastAPI, Asyncio, UVloop, Memory Optimization). Use when: python, fastapi, performance, asyncio, uvloop, pydantic, scalability, profiling."
license: CC-BY-SA-4.0
metadata:
  source: "agents/skills/coding/performant-python.skill.md"
  tags: "coding, python, architecture"
  core: "false"
  context_cost: "medium"
---
# Performant Python Skill

## Goal
Building high-concurrency, low-latency Python services by leveraging asynchronous patterns, optimized runtimes, and efficient memory management.

## Capabilities

### 1. Asynchronous Mastery (Asyncio & FastAPI)
- **Non-blocking I/O**: Use `async`/`await` for all network and disk I/O. Use `run_in_executor` for CPU-bound tasks to avoid blocking the event loop.
- **Event Loop Tuning**: Use `uvloop` as the drop-in replacement for the default asyncio loop for significant speedups.
- **Concurrent Execution**: Use `asyncio.gather()` or `asyncio.TaskGroup` (Python 3.11+) for parallel I/O operations.

### 2. Database & Data Handling
- **Async Drivers**: Use `asyncpg` for PostgreSQL or `aiomysql`. Use SQLAlchemy/Tortoise with async support.
- **Serialization**: Use `ORJSONResponse` or `UJSONResponse` in FastAPI for faster JSON encoding/decoding.
- **Efficient Models**: Use Pydantic v2 for its Rust-based speed. Use `.model_dump(include={...})` to minimize data transfer.

### 3. Memory & Resource Optimization
- **Slot Classes**: Use `__slots__` in frequently instantiated classes to reduce memory footprint and increase attribute access speed.
- **Generator Patterns**: Use `generators` and `yield` for processing large datasets to keep memory usage constant (O(1)).
- **Garbage Collection**: Tune `gc` thresholds if necessary, but prioritize object reuse to minimize pressure.

### 4. Deployment & Performance Runtimes
- **Process Management**: Use Gunicorn with `UvicornWorker` to scale across CPU cores.
- **Connection Pooling**: Always implement pooling for DB and HTTP clients (e.g., `httpx` instead of `requests`).
- **Middleware Overhead**: Audit and minimize middleware; each layer adds latency to every request.

### 5. Profiling & Monitoring
- **Deterministic Profiling**: Use `cProfile` for code path analysis.
- **Sampling Profiling**: Use `Py-Spy` or `Scalene` for production-safe, low-overhead profiling.
- **APM**: Integrate with Prometheus/Grafana or Datadog for real-time latency and throughput tracking.

## Steps
1. **Identify Blockers**: Use `Py-Spy` to find the hot paths in a running process.
2. **Async Audit**: Ensure no synchronous libraries (like `requests` or standard `psycopg2`) are used in an async context.
3. **Pydantic Check**: Upgrade to V2 and optimize model validation constraints.
4. **Benchmark**: Use `Locust` or `k6` to verify speed improvements under load.

## Deliverables
- `ARCHITECTURE_REVIEW_TEMPLATE.md`: Analysis of blocking calls and memory architecture.
- `SCALABILITY_ANALYSIS_TEMPLATE.md`: Roadmap for converting sync logic to async.
- `BENCHMARK_REPORT_TEMPLATE.md`: Response time comparisons (Before/After load testing).

## Security & Guardrails

### 1. Async Hazards
- **Race Conditions**: Be cautious with shared state (globals) in async contexts; use `asyncio.Lock` where necessary.
- **Loop Blocking**: Never run `time.sleep()` or heavy math in the main thread of an async app.

### 2. Data Security
- **Parameterization**: Ensure all DB queries are parameterized, especially when using raw SQL via async drivers.

### 3. Agent Guardrails
- **No Over-optimization**: Don't use `cython` or `numba` unless the pure Python/FastAPI path is fully optimized and still proves insufficient.
- **Versioning**: Ensure compatibility with Python 3.9+ for modern async features.
Files in this package (4)
  • ARCHITECTURE_REVIEW_TEMPLATE.md 8 KB
  • BENCHMARK_REPORT_TEMPLATE.md 1 KB
  • SCALABILITY_ANALYSIS_TEMPLATE.md 2 KB
  • SKILL.md 4 KB

Versions

The database has no other skills named performant-python.

Database snapshot: 13.11.2026 · package version f5172a4a51bf (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100fastapi-expert
    Expert-level FastAPI development for high-performance Python APIs with async support. Use when the user mentions Python, API, async, REST, OpenAPI, or Pydantic, or when the task involves FastAPI Features.
  • 100python-fastapi-pydantic
    Use this skill when building high-performance, asynchronous REST APIs in Python using FastAPI, Pydantic validation, and OpenAPI.
  • 100fastapi-service-engineering
    Engineering skill: FastAPI service — how to build and ship a api / service with FastAPI, Python, pytest + pytest-asyncio. Use when writing, reviewing, testing or releasing code in this stack, and when turning a Celestial design or experience skill into code.
  • 100async-python-patterns
    Async Python for high-performance services. Use when implementing FastAPI/Temporal/Kafka async handlers, AsyncSession database access, asyncio.gather concurrency, or diagnosing event loop blocking.
  • 100async-python-patterns
    Python asyncio and concurrent programming patterns for high-performance applications. Use when building async APIs, concurrent systems, or I/O-bound applications requiring non-blocking operations.
  • 95asyncio
    asyncio patterns, concurrency pitfalls, and backpressure. Use when writing async Python services.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.