-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
Summary
Python 3.14 is scheduled for release on October 7, 2025. We should upgrade policyengine-api to support Python 3.14 and take advantage of its performance improvements and new features.
Key Benefits for PolicyEngine API
Performance Improvements
- 3-5% geometric mean performance improvement - faster API response times
- Up to 30% faster for certain workloads with newer compilers
- Incremental garbage collection with reduced pause times
- Better throughput for concurrent requests
Free-Threaded Python (No GIL)
- Free-threaded mode is now officially supported
- Could enable true parallel request processing in Flask
- Potential to remove reliance on worker processes for concurrency
- Better utilization of multi-core systems
- Performance penalty in single-threaded mode reduced to just 5-10%
Concurrency Features
InterpreterPoolExecutor
for parallel policy calculations- Multiple interpreters in standard library
- Could improve API performance for batch calculations
- Better context variable and threading support
Type System Improvements
- Deferred evaluation of type annotations reduces import overhead
- Better type hint performance for API validation
- New
annotationlib
module for annotation introspection
Other Improvements
- Native Zstandard compression for faster data serialization/deserialization
- Improved error messages for better API debugging
- Enhanced HMAC implementation using verified code (security benefit)
- Simpler exception handling syntax (PEP 758)
Implementation Plan
- Wait for upstream dependencies - Ensure policyengine-core and country models support Python 3.14 first
- Update
pyproject.toml
to include Python 3.14 in supported versions - Add Python 3.14 to CI/CD test matrix
- Test API endpoints with Python 3.14
- Evaluate free-threaded mode for production deployment
- Update Google Cloud App Engine runtime configuration
- Update documentation
Priority
Medium-High - The API will benefit significantly from performance improvements and free-threaded mode. However, should wait for:
- Upgrade to Python 3.14 policyengine-core#399
- Upgrade to Python 3.14 policyengine-us#6626
- Upgrade to Python 3.14 policyengine-uk#1353
References
Metadata
Metadata
Assignees
Labels
No labels