Add new lecture on Python Static Typing
This PR adds a comprehensive new lecture on Python static typing to the "Advanced Python Programming" section of the lecture series. The lecture covers Python type hints syntax and their practical applications in scientific computing and economics.
Content Overview
The new lecture includes:
Core Concepts:
- Introduction to Python's type hint syntax (variables, functions, collections)
- Basic and advanced type annotations including generics and optional types
- Integration with static analysis tools (mypy, pyright)
Applications in Scientific Computing:
- Type hints for NumPy arrays and scientific workflows
- Economic modeling examples with proper type annotations
- Discussion of performance implications and JIT compilation
Current Ecosystem Status:
- Notes on Numba's current limitations with type hints
- Reference to JAX's roadmap for type annotation support
- Best practices for gradual adoption in existing codebases
Practical Examples: The lecture includes working code examples covering:
# Function annotations
def calculate_portfolio_value(
holdings: Dict[str, int],
prices: Dict[str, float]
) -> float:
# Implementation with type safety
# Economic modeling with types
class EconomicParameters(NamedTuple):
alpha: float # Capital share
beta: float # Discount factor
delta: float # Depreciation rate
The lecture addresses modern development needs where type hints are increasingly important due to:
- Better IDE support and error detection
- AI/LLM code generation often including type annotations
- Improved code documentation and team collaboration
- Future JIT compiler optimizations
Integration
- Added as lecture #21 in the "Advanced Python Programming" section
- Properly integrated into the table of contents between "Writing Good Code" and "More Language Features"
- Includes three practical exercises for hands-on learning
- All code examples are executable and tested
Fixes #343.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
fred.stlouisfed.org
- Triggering command:
/usr/share/miniconda/envs/quantecon/bin/python -Xfrozen_modules=off -m ipykernel_launcher -f /tmp/tmpetg935ef.json --HistoryManager.hist_file=:memory:(dns block)jax.quantecon.org
- Triggering command:
/usr/share/miniconda/envs/quantecon/bin/python /usr/share/miniconda/envs/quantecon/bin/jb build lectures --path-output ./ -n -W --keep-going(dns block)- Triggering command:
/usr/share/miniconda/envs/quantecon/bin/python /usr/share/miniconda/envs/quantecon/bin/jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.