Performance: identify hot paths that can use C extension bindings #16

Open
opened 2026-05-05 00:21:40 +10:00 by unkinben · 0 comments
Owner

Audit the codebase for Python hot paths that have available C-accelerated alternatives. Candidates: JSON serialisation (orjson instead of stdlib json — drop-in for FastAPI with response_class=ORJSONResponse); datetime parsing (ciso8601 or pendulum); S3 streaming (aiobotocore already uses C extensions, verify); SQLAlchemy query compilation (psycopg3 C extension vs asyncpg); JWT decode (use PyJWT with cryptography C backend, already in deps). Profile first with py-spy or cProfile on a representative workload to confirm actual hot paths before switching. Low-risk wins: orjson is ~10x faster than stdlib json and requires minimal code change.

Audit the codebase for Python hot paths that have available C-accelerated alternatives. Candidates: JSON serialisation (orjson instead of stdlib json — drop-in for FastAPI with response_class=ORJSONResponse); datetime parsing (ciso8601 or pendulum); S3 streaming (aiobotocore already uses C extensions, verify); SQLAlchemy query compilation (psycopg3 C extension vs asyncpg); JWT decode (use PyJWT with cryptography C backend, already in deps). Profile first with py-spy or cProfile on a representative workload to confirm actual hot paths before switching. Low-risk wins: orjson is ~10x faster than stdlib json and requires minimal code change.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unkin/streamstack#16