Django Modern REST, Python 3.15, and Memory Optimization
High-Performance Web Development
Django Modern REST
This episode dives into Django Modern REST, a new framework designed for developers who want the flexibility of Django combined with the type-based magic and async capabilities seen in FastAPI or Django Ninja. Key features include:
• Multi-model support: Works with Pydantic, Atters, MessageSpec, and even TypedDict.
• High throughput: Using MessageSpec can lead to APIs that are significantly faster in data serialization.
• AI integration: Includes built-in support for LLMs.txt, making it exceptionally easy for AI agents to understand and assist with project maintenance.
Cutting Python Web App Memory
Michael discusses his practical journey toward optimizing his infrastructure for TalkPython and Python Bytes, resulting in a massive savings of over 1.9 GB of RAM. Key strategies included:
• Async migration: Transitioning from sync Pyramid to Quart allowed for fewer worker processes.
• Subprocess Offloading: Moving heavy, infrequent tasks (like indexing) to separate subprocesses ensures that their large memory footprint is transient.
• Lazy Imports: By delaying imports (moving them inside functions), he eliminated the need to load heavy libraries like Pandas or Matplotlib for every single request.
Python 3.15 and Testing Innovations
Progress on 3.15
Excitement abounds regarding the development of Python 3.15, especially with the arrival of:
• Explicit Lazy Imports (PEP 8.10): Expected to drastically reduce startup times.
• Frozen Dictionaries: A new built-in type that will be excellent for concurrency in the new free-threaded world.
Trike Test Runner
Trike is a new Rust-based test runner with a Jest-style API. It differentiates itself from PyTest by offering:
"Soft assertions by default, allowing you to collect multiple failures rather than stopping on the first one."
• Uses client-server architecture to keep a warm cache of the codebase.
• Promotes a fluent API (e.g., expect(value).to_be(...)) for greater readability.
Fun & Community
Finally, the hosts touch upon the humorous HumanDB project—an April Fool's joke that claims to be a "human-powered analytical database." They also discuss how modern agentic AI tools are making the maintenance of open-source projects (like Beanie) substantially easier and more sustainable.