Python Bytes

#445: Auto-activate Python virtual environments for any project

Topics covered in this episode:

  • pyx - optimized backend for uv
  • * Litestar is worth a look*
  • * Django remake migrations*
  • * django-chronos*
  • Extras
  • Joke
Watch on YouTube

About the show

Python Bytes 445

Sponsored by Sentry: pythonbytes.fm/sentry - Python Error and Performance Monitoring

Connect with the hosts

  • Michael: @mkennedy@fosstodon.org / @mkennedy.codes (bsky)
  • Brian: @brianokken@fosstodon.org / @brianokken.bsky.social
  • Show: @pythonbytes@fosstodon.org / @pythonbytes.fm (bsky)

Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.

Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.

Michael #1: pyx - optimized backend for uv

  • via John Hagen (thanks again)
  • I’ll be interviewing Charlie in 9 days on Talk Python → Sign up (get notified) of the livestream here.
  • Not a PyPI replacement, more of a middleware layer to make it better, faster, stronger.
  • pyx is a paid service, with maybe a free option eventually.

Brian #2: Litestar is worth a look

  • James Bennett
  • Michael brought up Litestar in episode 444 when talking about rewriting TalkPython in Quart
  • James brings up
    • scaling - Litestar is easy to split an app into multiple files
    • Not using pydantic - You can use pydantic with Litestar, but you don’t have to. Maybe attrs is right for you instead.
  • Michael brought up
    • Litestar seems like a “more batteries included” option.
    • Somewhere between FastAPI and Django.

Brian #3: Django remake migrations

  • Suggested by Bruno Alla on BlueSky
  • In response to a migrations topic last week
  • django-remake-migrations is a tool to help you with migrations and the docs do a great job of describing the problem way better than I did last week
  • “The built-in squashmigrations command is great, but it only work on a single app at a time, which means that you need to run it for each app in your project. On a project with enough cross-apps dependencies, it can be tricky to run.”
  • “This command aims at solving this problem, by recreating all the migration files in the whole project, from scratch, and mark them as applied by using the replaces attribute.
  • Also of note
    • The package was created with Copier
    • Michael brought up Copier in 2021 in episode 219
    • It has a nice comparison table with CookieCutter and Yoeman
    • One difference from CookieCutter is yml vs json.
    • I’m actually not a huge fan of handwriting either. But I guess I’d rather hand write yml.
    • So I’m thinking of trying Copier with my future project template needs.

Michael #4: django-chronos

  • Django middleware that shows you how fast your pages load, right in your browser.
  • Displays request timing and query counts for your views and middleware.
  • Times middleware, view, and total per request (CPU and DB).

Extras

Brian:

  • Test & Code 238: So Long, and Thanks for All the Fish
    • after 10 years, this is the goodbye episode

Michael:

  • Auto-activate Python virtual environment for any project with a venv directory in your shell (macOS/Linux): See gist.
  • Python 3.13.6 is out.
  • Open weight OpenAI models
  • Just Enough Python for Data Scientists Course
  • The State of Python 2025 article by Michael

Joke: python is better than java