Learn Python with Talk Python's 270 hours of courses

AI Goes on Trial For Writing Code (crossover)

Episode #396, published Fri, Dec 30, 2022, recorded Tue, Nov 29, 2022

For links and very detailed show notes, please view the original episode page over on Python Bytes. Thanks for listening!

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guests Introduction and Background

Brian Okken is the co-host of the Python Bytes podcast and the author of Python Testing with pytest. He’s deeply involved in the Python testing community and brings a wealth of experience in software best practices. Brian is passionate about helping developers write clean, reliable tests and fostering better engineering processes.


What to Know If You’re New to Python

If you’re newer to Python, some concepts in this episode (like async/await, using AI coding tools, and building small GUI dialogs) might be unfamiliar. Understanding basic Python syntax, modules, and how to install packages will help. Here are a few quick resources mentioned or implied in the conversation:


Key Points and Takeaways

  1. GitHub Copilot Litigation and the Future of AI Code Generation This episode’s headline topic centers on the class action lawsuit challenging GitHub Copilot’s legality, specifically its training on open-source code without proper attribution. Microsoft, OpenAI, and GitHub are all named as defendants, and the lawsuit raises big questions about how AI tools handle licensed material. The discussion highlights both the power and potential pitfalls of AI in coding, including copyright concerns and code ownership.
  2. Simon Willison’s Talk on Personal Project Documentation and Testing Brian discusses Simon’s “Coping Strategies for the Serial Project Hoarder,” emphasizing the “perfect commit” philosophy: each commit should include code, tests, and documentation. By writing down ideas and even dead ends in issue threads, you build “temporal documentation” that helps you pick up old projects faster. This approach ties well into a professional software development mindset, whether you work on personal or corporate code.
  3. Using ctypes for Native Windows Dialogs For quick pop-ups on Windows, you don’t need extra dependencies. The show highlights how you can call MessageBox from the Windows API via Python’s built-in ctypes, which keeps the interface completely native. This is a handy trick for scripts that need minimal user interaction but must look and behave like a standard Windows app.
  4. Writing Chrome Extensions in Python with PyScript The episode explores how PyScript allows developers to run Python directly in the browser via WebAssembly. One example shared is creating a Chrome extension using Python logic without the usual JavaScript. While still in early stages, PyScript opens the door for browser-based Python experiments and simpler prototypes.
  5. PyScript Powered by MicroPython A performance concern with PyScript is that it relies on a heavy WebAssembly build of CPython. The latest innovation is using MicroPython, which drastically reduces load times and memory usage in the browser. This shift enables Python-based front-ends that are more comparable in size to typical JavaScript frameworks, making interactive web Python more viable.
  6. Takahe: Async Python for Mastodon-Style Instances The conversation touches on Andrew Godwin’s Takahe project, which reimplements Mastodon-like functionality in Python using async features. This approach aims to make it easier to host multiple user domains and keep resource overhead low. Takahe’s design emphasizes simpler DevOps requirements than Mastodon’s standard Ruby-based ecosystem.
  7. Mastodon Scaling and the Benefits of Async Python Traditional Mastodon servers in Ruby face challenges with concurrency and performance (due to global interpreters and blocking I/O). The episode briefly contrasts how Python’s async and await can handle non-blocking network calls more gracefully, allowing higher concurrency without multiple OS-level threads. This is one reason many new Fediverse tools are exploring async Python.
  8. CDNs and Nginx Bottlenecks Michael and Brian discuss real-world performance issues when a site experiences heavy traffic, such as during Black Friday. Surprisingly, it was Nginx (not the Python code) hitting 90%+ CPU usage when serving static files. Offloading static resources to a CDN dramatically reduced the load and improved site speed, underscoring how crucial a CDN can be to web apps’ success.
  9. Kite Shuts Down Kite was one of the earliest AI-based coding assistants, predating GitHub Copilot. The episode briefly covers Kite’s closure, pointing out how challenging it is to scale a business around AI coding suggestions—especially once bigger players (like Microsoft and GitHub) enter the field.
  10. Rivers Cuomo, Guido van Rossum, and Python Culture A fun discussion popped up about musician Rivers Cuomo (of Weezer) and Guido van Rossum (Python’s creator) appearing on the Sing for Science podcast. It’s a quirky intersection of Python and pop culture, showcasing how broad the Python community’s influence can be.
  1. Planet Python and the Power of Technical Blogging Simon Willison’s approach to logging personal dev notes leads to a broader conversation: there’s a shortage of consistent Python blogging these days. Brian suggests checking out aggregators like Planet Python for fresh content and encouraging developers to share short-form blog posts (even if it’s just a few paragraphs) to keep the knowledge flowing.

Interesting Quotes and Stories

  • Brian on Documenting Every Step: “He calls it temporal documentation. And I just love this idea... you can just dump it there, so you don’t have to remember anything.”
  • Michael on Cookiecutter: “I always want to have logging set up like this, connect to that monitoring service—just run one command, and it’s there.”

Key Definitions and Terms

  • Temporal Documentation: A style of writing all interim thoughts and steps in an issue thread or commit message so future developers (and your future self) can quickly pick up the context.
  • Cookiecutter: A tool to create project boilerplate from predefined templates, saving time and ensuring consistency across projects.
  • WebAssembly: A low-level, assembly-like language that runs on modern web browsers, enabling near-native performance for languages like Python via projects such as PyScript.
  • Async/Await: Python keywords used to write concurrent code without creating multiple threads, reducing overhead for I/O-bound processes.
  • CDN (Content Delivery Network): A geographically distributed network of servers that store cached static content like images and CSS files, delivering them from nodes closest to the user.

Learning Resources

Here are resources to learn more and go deeper into the topics mentioned in this episode:


Overall Takeaway

The conversation underscores the growing importance and complexity of AI-driven coding tools, as well as how best practices (like solid documentation, testing, and scaling strategies) remain constants amid change. Whether exploring new ways to run Python in the browser, adopting async frameworks, or simply spinning up native GUI windows on Windows with minimal fuss, the Python ecosystem offers a world of inventive possibilities. Above all, an engaged community and a willingness to share both insights and stumbling blocks can make projects more resilient, future-proof, and enjoyable to maintain.


Talk Python's Mastodon Michael Kennedy's Mastodon