MPCS 51052 - Advanced Python Programming

Course Overview

This course explores a wide variety of programming concepts using Python and its vast ecosystem as a foundation. The goal is to explore advanced programming & software design concepts using newer features of the Python language as well as third-party libraries. The course will make heavy use of open source libraries & Python’s own code to understand how Python is written and what constitutes good “Pythonic” design.

Topics will include:

Python as an evolving language. What’s new in Python? How and why does the language evolve & what has been added recently? What tools are Python developers using today?

Metaprogramming & “power-user” features. What are the parts of Python’s syntax & libraries that aren’t used every day that can lead to more expressive code? We’ll look at generators/coroutines, context managers, decorators, descriptors & other features typically not covered in earlier courses. How do they work internally? When do you use them?

Python & the web. Why is Python such a popular language for web development? We’ll use this as a jumping off point to discuss trade-offs in library design and work with libraries like Django, Flask, Starlette, FastAPI, etc.

Asynchronous programming in Python. What is the GIL? Why are there so many ways to do asynchronous work in Python & which are worth using? We’ll also explore some async web frameworks to see real-world usage.

Making Python faster. How write the most performant Python you can, and what to do when that still isn’t fast enough. We’ll touch on Python’s C API, PyPy and other alternate interpreters, and enhancing Python with Rust.

The course will have regular programming assignments as a well as a final project.

Goals

  • Gain a deeper understanding of Python’s newer & more advanced features, with an eye towards language mastery.
  • See how common real-world tasks like parallel & web programming push the limits of Python and the solutions that have arisen since.
  • Explore the Python ecosystem to better understand library API design and real-world performance considerations.
  • Gain experience building a full application in Python through the course project.

Office Hours

  • Mondays 2-3pm - Adi (JCL Common Area TBD)
  • Tuesdays 12:30-1:30 - James (JCL 398E)
  • Wednesdays 11:30am-1pm - James (JCL 398E)

James also has time available to schedule 1:1 via: https://cal.com/jamesturk/

Schedule

Class will meet: Tuesday/Thursday 11am-12:20pm in JCL 011

Schedule subject to change, major changes will be announced in class and on Ed Discussion.

Week Tues Thurs Due (Mon)
1. Evolving Python Course Intro / How Python Evolves Writing “Modern” Python in 2026 M1
2. Solid Python Typing Testing in Practice A1; A2
3. Metaprogramming Python Metaprogramming Metaclasses A3
4. Practical Python Evolution of Dataclasses Coroutines A4; M2
5. Async Python The Notorious G.I.L. asyncio A5
6. Web Python Web Frameworks async web A5b
7. Faster Python Profiling Alternate Interpreters A6
8. Extending Python C API Other Extensions A7; M3
9. Future Python GIL-free Python __future__ A8
10. Final Week: Project Showcase - - M4; A9

Assignments

There are ten assignments in this class, as well as a quarter-long project with a few milestones.

Number Name Type Due
A1 PEP Report Written Fri. April 3
A2 New Syntax Practice PA Fri. April 3
A3 Typing & Testing PA Mon. April 13
A4 Metaprogramming PA Mon. April 20
A5 Coroutines PA Mon. April 27
A5b Async PA Mon. May 4
A6 Web API PA Mon. May 11
A7 PyCon Report Written Mon. May 18
A8 Extension PA Mon. May 25
A9 PEP Written Mon. May 25

Programming Assignments

There are 7 PAs: A2, A3, A4, A5, A5b, A6, A8.

For each, will be provided with an existing codebase with functions/methods to implement and fix.

These are designed to give practice with new concepts in the language to build & test your understanding of how to use these features.

5 and 5b These PAs are related to one another. It is not possible to complete 5b without first finishing 5. This is noted so you can plan accordingly.

Written Assignments

Three written assignments (A1, A7, A9) will involve doing outside reading/watching a presentation and writing an Ed post on what you’ve learned. This will let you explore topics at a deeper level than what we can cover in class, help build your technical communication skills, and give practice learning challenging technical content on your own.

Assignment 1: PEP Report

Pick a PEP.

Your choice should either be a Finished PEP from a recent version (Python 3.11 or later), or one in the Accepted or Open phase. The PEP must be about the language itself (no release note, tutorial, or governance PEPs).

Read your chosen PEP and write an Ed post with the following sections:

  • Summary: Summarize the core ideas of the PEP in your own words. Why is it interesting to you?
  • Alternatives: What else is/was being considered?
  • Example: Write a piece of example code that shows how the PEP would be used. This example must be original, not borrowing from the example in the PEP itself. Take time to understand what the PEP does and how code would be improved by adopting the new syntax/feature.
  • Link to implementation: Your PEP most likely mentions a “bpo” number, an issue in the Python bug tracker. For example, PEP 674 mentions https://github.com/python/cpython/issues/89639. Using these link(s) (there may be a few), try to find the relevant Git PR/commits that implement the PEP. Provide a link to the implementation, or if you cannot find one, the relevant issues.
  • Opinion: What is your opinion on this PEP? Would you have voted to accept it or not?

Assignment 7: PyCon Talk Review

Details on this assignment will be updated during the quarter.

Assignment 9: Drafting a PEP

For this assignment, you will be writing a PEP of your own.

Based on everything we’ve covered in class, and everything you know about Python from using it– what enhancement do you want to add? You might consider:

  • Something that bugs you about the way Python works that you think can be fixed.
  • A piece of syntax from another language you miss when using Python.

Write your PEP according to the guidelines in PEP 1, which includes templates for writing new PEPs as well as the expected sections.

We will discuss the PEPs created by the class as a group.

Course Project

The course project consists of several milestones:

  • M1: Proposal - Week 1.
  • M2: Architecture Plan - Week 4.
  • M3: Prototype - Week 7.
  • M4: Final Product - Week 10, when final is scheduled.

This is an advanced programming course and I’d like to give you the chance to build something that is interesting to you and lets you explore some of the topics covered in class.

This project will require you to apply skills you learn in class, augmented with self-guided learning.

The main requirement is that you build a complete program that makes meaningful use of Python: a CLI/TUI app, web application, GUI application, game, etc.

The purpose of your program is up to you, but must satisfy the requirements listed under M4.

You may work independently or in teams of two. (See R9/R10 below for extra requirements for teams of two.)

M1: Proposal

By 11:59pm on Saturday of Week 1, you must submit a proposal outlining what you would like to build, and after skimming the course outline, a sense of how you might meet R5 (and potentially R10) below.

Your proposal should include sufficient detail for course staff to provide meaningful feedback. For most projects that would mean a few paragraphs, and possibly a quick sketch or two.

M2: Architecture Plan

A more detailed version of your proposal, sketching out your proposed architecture.

Details will be shared after M1.

M3: Prototype

To ensure things are on track, a partially-working prototype is due for the third milestone. This will give you a chance to assess how much is left to do, how your plan needs to change, and to give course staff the opportunity to suggest changes and help you plan for the final stretch.

Details will be shared after M2.

M4: Final Product

Your final submission must meet the following requirements:

  • R1: Complete python application. Your application should be packaged in a way where it is possible for someone to git clone and uv run with minimal additional steps. The application should be laid out according to best practices and pass ruff checks with minimal ignores.
  • R2: Well-tested. Your application should have essential functionality tested and correct, following best-practices discussed in class.
  • R3: Well-typed. Your application must be typed, and pass type checks with minimal ignores.
  • R4: Documentation: A complete README with images or video as well as architecture & code documentation.
  • R5: A correct & non-trivial usage of least one “advanced” feature. Examples:
    • Metaprogramming: A domain-specific-language, plugin system, or other advanced usage implemented with metaprogramming techniques.
    • async: Use of async/await/asyncio.
    • A custom-written extension in C, Rust, Cython, RPython, etc. that makes a notable difference in the program’s performance.
    • Equivalent alternatives may be suggested as part of M2, subject to approval.
  • R6: Code is mostly correct & well-written. This both means writing Pythonic code as well as ensuring your code is efficient.
  • R7: Novelty. Code does something novel & interesting– not simply a reimplementation of something that has been built before. (It OK to build a “better” version of something that you’ve seen done, but you should have a unique take!)
  • R8: Code Review. You must have your code reviewed by a peer (not on your team), and review their code. Specifics on this component will be shared around Milestone 3.

If you are working on a team, you’ll have two additional requirements:

  • R9: Use of mocks to build independently of one another. Will be discussed as part of M2.
  • R10: A second advanced feature. Either from the R5 list, or you may propose an alternate at the same or greater level of complexity that fits your project’s needs. Each team member must be responsible for a significant portion of one of the two advanced features, R5 and R10.

Solo projects will receive an automatic S on these two milestones.

Additionally, you must participate in the Week 10 project presentations in lieu of a final exam. Failure to participate will result in three deductions to your M4 grades.

Grading

We’ll be using specifications grading. You will be given a set of specifications of what makes work Satisfactory, Not satisfactory, or Ungradable.

Some assignments will have additional criteria to qualify for an Exceptional grade._

Final Grade Calculation

There are 23 available grades:

Component Points
Assignments 10
Project Milestones 1-3 3
Project Requirements 10

Each of these will receive an ESNU score:

Letter Point Value Description
E 1.5 Awarded for exceeding the base criteria on an assignment.
Only available on a few assignments.
S 1 Awarded for meeting base criteria for an assignment with minimal errors.
N 0.5 Work that fails to meet the established base criteria but represents a solid effort.
U 0 Work that is incomplete or otherwise ungradable.

Note: Obtaining an E will often be challenging, the intention is that one would only choose to attempt the E criteria on a few assignments.

Letter Grade Required Points
A 20
A- 19
B+ 18
B 17
B- 16
C+ 15
C 14
C- 13

There is a lot of potential work in this class, and the assumption is that most people will opt to skip a few assignments.

For example: You may decide that your project is giving you plenty of practice with web development, and skip the relevant assignment.

It is up to you to decide what grade you are aiming for and which assignments will most benefit you.

Warning

Academic Honesty violations, including unauthorized use of AI, will earn U on affected assignments and be ineligible for resubmission. Additionally, the highest grade you will be eligible to earn will be a B.

C- is the minimum grade to receive credit for this course.

If you feel that you are at risk of falling behind reach out to James proactively to discuss options.

AI Addendum

This course falls under my general policy on generative AI with the following rules:

  • You may not use an LLM to generate text or code for assignments A1-9 unless otherwise stated. The grading policy is such that serious attempts at solutions will earn an N even if far from perfect! An N is a minor penalty far preferable to a U/capped grade!
  • For your project, limited use of generative AI will be allowed provided you follow the citation rules.

Resubmission & Late Policy

  • Any assignment 1-72 hours late will be capped at an N, work after 72 hours will be given a U.
  • You may resubmit one of the programming assignments. These resubmissions will be due by Week 9 and give you a chance to improve a previously-earned grade.
  • Written assignments and project milestones may not be resubmitted.
  • Resubmissions can be used as an effective extension to account for life events or busy weeks. Otherwise, no late work will be accepted.
  • Exceptions will only be made in the rare case of serious illness or major emergencies. I will ask that you have your advisor reach out to me.