Python Web Frameworks: Sanic, FastAPI, and Open Source

·53m 44s
Shared point

Python Project Best Practices

Clean Code Techniques

Break down functions and files: Smaller units, like functions or modules based on single responsibility, are easier to manage and test.
Avoid magic numbers: Use defined constants to increase readability.
Limit global scope: Especially in larger files, keep variables and functions within clear, localized modules to avoid unintended side effects.
Use automation: Incorporate linters (Black, Flint, pre-commit) to maintain consistent code styles automatically.

Open Source Health & Maintenance

Closevember initiative: A month dedicated to helping maintainers clean up issues, review pull requests, and manage project backlogs to combat burnout.
Helpful collaboration: Improve documentation, reproduce bugs, and offer to close stale issues to support maintainers significantly without changing deep code.

Web Framework Developments

Sanic Enhancements

"One of the things that we sort of had noticed and really drove us to what ultimately became the worker manager feature is that Sanic comes out of the box with... auto-reload, the ability to scale up multiple workers."

Worker Manager: A new Sanic feature allowing for the management of arbitrary child processes alongside the main web server, useful for tasks like chatbots or scheduled cron-like jobs.
Improved Production Stability: The new structure ensures consistent behavior across development and production environments.

FastAPI Updates

Infrastructure Upgrades: FastAPI updated to use HTTPX for the test client, with tools available like bump-test-client to help transition existing tests.
Community Engagement: New documentation sections help external contributors assist with GitHub issues, effectively acting as an extension of the maintainer team.

Tooling & Community

Mastodon: The Python community is increasingly adopting this federated platform, offering a fresh, community-driven alternative to mainstream social media.
Cashews: A new async caching framework offering advanced features like cache-on-top-of-cache, rate limiting, and circuit breakers to improve performance and reliability.

Topics

Chapters

7 chapters
Python Bytes
AI chat — answers grounded in episodes