Skip to content

Add new lecture on Python Static Typing #392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 15, 2025

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 add update for PR #52 on sphinxcontrib-tomyst #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:


💡 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.

Co-authored-by: mmcky <8263752+mmcky@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] [New Lecture] Python Static Typing Add new lecture on Python Static Typing Aug 15, 2025
@Copilot Copilot AI requested a review from mmcky August 15, 2025 09:49
Copilot finished work on behalf of mmcky August 15, 2025 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New Lecture] Python Static Typing
2 participants