Brian Okken: Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
Brian Okken: This is episode 455, recorded October 27th, 2025.
Brian Okken: And I'm Brian Okken.
Brian Okken: I'm Michael Kennedy.
Brian Okken: And this episode is sponsored by the wonderful people at Python Bytes.
Brian Okken: Actually, both and everybody here.
Brian Okken: So please check out the work we do for a little bit of money.
Brian Okken: We've got Talk Python training with tons of wonderful courses.
Brian Okken: And his new book, of course, Michael's new book.
Brian Okken: And then also, if you want to check out pytest, there's the complete pytest course.
Brian Okken: Or you can take the pytest course at Talk Python Training.
Brian Okken: And as always, thank you to our Patreon supporters.
Brian Okken: You guys rock.
Brian Okken: We don't shout you out all the time, but we always appreciate you.
Brian Okken: If you'd like to submit a topic idea or some feedback for us or just say hi,
Brian Okken: Check out the show notes at pythonbytes.fm.
Brian Okken: There's links to our socials.
Brian Okken: We've got the show, and both Michael and I are on Bluesky and Fosstodon,
Brian Okken: but that's really Mastodon, so wherever you're at there.
Brian Okken: If you're listening to this and you're like,
Brian Okken: what, sounds like they're recording live somewhere.
Brian Okken: We can see it.
Brian Okken: Yes, we are recording and streaming,
Brian Okken: but you can watch all the back episodes or participate in the chat if you want to.
Brian Okken: Check out pythonbytes.fm/live with all the details there and a link to when we're going to record next.
Brian Okken: Before we get started, one last thing.
Brian Okken: We do send out a newsletter that's getting better and better as we go along,
Brian Okken: thanks to both Michael and I working on it a little bit.
Brian Okken: So there's a newsletter we send out with all the links.
Brian Okken: So you don't have to take notes.
Brian Okken: We'll send you out an email.
Brian Okken: So sign up for the newsletter and we'll send you those links and extra details too.
Brian Okken: It's a great resource.
Brian Okken: Yeah, I think people really appreciate it, Brian.
Michael Kennedy: You know, if you look at when you send out the email and then book back in the campaign
Michael Kennedy: and how many people actually open to the thing that we send out or click on it,
Michael Kennedy: those are really close to 100%, which is ridiculous.
Michael Kennedy: So that's a really good sign that other people might also like it.
Brian Okken: Yeah, I think that people are using it in place of taking notes.
Brian Okken: And also, if you're in a car or something, you don't want to try to remember.
Brian Okken: You don't have to.
Brian Okken: So awesome.
Brian Okken: All right, Michael, what do you got for us right away?
Michael Kennedy: Well, let me see what I can do here.
Michael Kennedy: Let's see what the Cyclops says.
Michael Kennedy: A Cyclops.
Michael Kennedy: It's like a little programming kitty, but it's a Cyclops.
Michael Kennedy: It's a cute.
Brian Okken: Like Opt, O-P-T.
Brian Okken: operations cycle.
Michael Kennedy: I get it.
Michael Kennedy: So we've heard of Click.
Michael Kennedy: You and I were both just actually singing
Michael Kennedy: the praises of ArgPars,
Michael Kennedy: which is pretty interesting.
Michael Kennedy: I am such a fan of ArgPars these days
Michael Kennedy: because it's just built in and it's
Michael Kennedy: simple and it's good enough.
Michael Kennedy: If you were building
Michael Kennedy: something where the CLI
Michael Kennedy: API or interface
Michael Kennedy: or dev user experience was super
Michael Kennedy: important, you might choose something
Michael Kennedy: other than ArgPars.
Michael Kennedy: So what are your options?
Michael Kennedy: You could choose Click, you could choose Typer.
Michael Kennedy: Typer is actually built on Click, so in a sense it's like Starlette and FastAPI.
Michael Kennedy: You choose one, you get the other in a sense.
Michael Kennedy: So there's a blend there, and there's others.
Michael Kennedy: I know there's a bunch of different CLI building options.
Michael Kennedy: But the Cyclops is one that sort of has the second mover advantage over Typer.
Michael Kennedy: And their sort of tagline, I don't remember where I saw it, but
Michael Kennedy: somewhere in here, it's not actually right here on this page.
Michael Kennedy: but no shade at typer, but it says what you thought typer was going to be.
Michael Kennedy: And my second boomer advantage is like, all right,
Michael Kennedy: we've seen different interface things built based around type information.
Michael Kennedy: And now that we've seen the pluses and the minuses,
Michael Kennedy: could we do a slightly different version that has more pluses and fewer minuses?
Michael Kennedy: And so there's a whole page of the typer comparison here.
Michael Kennedy: And I'm not a super expert on typer.
Michael Kennedy: My CLI, who is not that great.
Michael Kennedy: So there's 13 different things, 13 different components or features or aspects of the API
Michael Kennedy: that they chose to address to say, Typer's great.
Michael Kennedy: We're basically inspired by Typer.
Michael Kennedy: That's what we're doing.
Michael Kennedy: However, there's a couple of these 13 areas I think we should make better, right?
Michael Kennedy: So you could actually go through and look at all of them.
Michael Kennedy: Probably the biggest one is that Typer was made with Python 3.7, 3.8,
Michael Kennedy: where Python's types were at an earlier stage in their life.
Michael Kennedy: You had to say things like, this is an argument of int,
Michael Kennedy: or it is an int when it's actually an argument of int or something like that.
Michael Kennedy: And this Cyclops thing was built once annotated was introduced,
Michael Kennedy: which allows you to have sort of a dual role.
Michael Kennedy: Like, it really is one of these, but its type could also be like its native value, right?
Michael Kennedy: Allowing the removal of proxy defaults.
Michael Kennedy: Why does that matter?
Michael Kennedy: Because if you build a CLI with Cyclops,
Michael Kennedy: and you use types,
Michael Kennedy: you can still use it as regular functions
Michael Kennedy: as if they just had an integer
Michael Kennedy: where it said it took an integer and so on.
Michael Kennedy: So things like that.
Michael Kennedy: It's got about, I think,
Michael Kennedy: a thousand GitHub stars or so.
Michael Kennedy: It's not crazy, crazy popular.
Michael Kennedy: But if you're really loving that concept
Michael Kennedy: of having types for your CLI,
Michael Kennedy: give this thing a look.
Brian Okken: Yeah, actually, I got a shout out to him
Brian Okken: for doing things like comparing to Typer
Brian Okken: because, like you said, a lot of us, I use Cyper as well.
Brian Okken: And I've used Typer, I've used Click and ArgParse.
Brian Okken: And so you're probably not going to grab too many of the ArgParse people
Brian Okken: because they're just using it because it's built in, maybe.
Michael Kennedy: You're like the unit test people, Brian.
Michael Kennedy: What can you do?
Michael Kennedy: You talk pytest for 10 years.
Brian Okken: I yell louder.
Brian Okken: That's what I do.
Brian Okken: But I think it's a fair thing because I'd be thinking, well, if I'm not going to use ArgParse, I'm probably going to reach for Typer or Click, lately Typer.
Brian Okken: But having this comparison here and then even a migration from Typer, I think that's cool to show that.
Brian Okken: And there's always room for making CLI tools better.
Brian Okken: We love CLI tools.
Brian Okken: Yeah.
Brian Okken: Yeah, there definitely are.
Michael Kennedy: But yeah, so cool.
Michael Kennedy: I ran across this and I built something with it recently and it was nice.
Oh, did you?
Checking out.
Brian Okken: Yeah.
Michael Kennedy: A little, you know, I'm starting to add.
Michael Kennedy: I've been kind of, I've drunk the Kool-Aid now that maybe having an actual CLI,
Michael Kennedy: even from my own tools, might be a little bit better than just,
Michael Kennedy: here's a script I run and maybe I'll pass it something
Michael Kennedy: and just look at sys.argv and see if it's in there.
Oh, man.
Michael Kennedy: Let's do a little bit better.
Michael Kennedy: And now that I've started to do that, I've been playing with these different ones,
Michael Kennedy: which is, I think, where I kind of got inspired to go down this path and talk about it today.
Brian Okken: Yeah, awesome.
Brian Okken: Cool.
Brian Okken: I want to talk about the present, the future, a little bit of both.
Brian Okken: So there is this interesting article, of course, in Python 3.14.
Brian Okken: Well, we had it in 3.13, is that the GIL was optional with what they call the free threading version, right?
Brian Okken: Free threaded Python.
Michael Kennedy: Not the gill-less, not the galectomy.
Michael Kennedy: Free-threaded, I think, is where we landed from the PEP.
Brian Okken: Okay, but is it kind of the same thing?
Brian Okken: Yeah.
Brian Okken: Okay.
Brian Okken: Oh, right.
Brian Okken: The galectomy was a different project.
Brian Okken: Yeah, it was.
Michael Kennedy: Gosh.
Michael Kennedy: Anyway.
Michael Kennedy: Larry Hastings was doing that.
Michael Kennedy: But I believe, I mean, the free-threaded stuff,
Michael Kennedy: there's a lot of things that had to happen.
Michael Kennedy: And actually, my next topic is also on free-threaded Python.
Michael Kennedy: And it's not just let's take out the gill,
Michael Kennedy: but they had to rework memory management.
Michael Kennedy: the structure of object.
Michael Kennedy: There's like a lot of moving parts
Michael Kennedy: in order to make this possible.
Brian Okken: Okay, cool.
Brian Okken: Okay, so with the free-threaded Python,
Brian Okken: so now we have in 3.13,
Brian Okken: we had two versions of Python released.
Brian Okken: So if you go to download Python,
Brian Okken: you get a choice.
Brian Okken: And with UV2, you can add a T to it, 3.14 T,
Brian Okken: and you get the free-threaded version.
Brian Okken: But like, and also definitely encourage everybody
Brian Okken: test and publish that you've tested.
Brian Okken: In CI, you go ahead and test it because the CI tools support both.
Brian Okken: Why do we care about this?
Brian Okken: Well, because some people are migrating to it because as with 3.14,
Brian Okken: it's no longer just an experimental thing.
Brian Okken: So here, I'm going to cover an article by Giovanni Barili.
Brian Okken: Sorry, Giovanni.
Brian Okken: I can pronounce that one.
Michael Kennedy: I'm pretty sure this is the same Giovanni that makes Granian.
Brian Okken: Oh, okay.
Brian Okken: I think so.
Brian Okken: The future of Python web services looks gill-free.
Brian Okken: So it starts out with two major changes when comparing free-threaded variant of 3.14 versus 3.13.
Brian Okken: First, free-threaded support now reaches phase two, meaning it is no longer considered experimental.
Brian Okken: So everybody's on board with this is what we're going to at least try to do for a while.
Brian Okken: not just try to do but we're the python core team is supporting this and we're going to do it
Brian Okken: moving forward what does that mean it means that people can depend on a free threaded version and
Brian Okken: change their code accordingly if necessary which is great especially for a lot of async stuff
Brian Okken: like web services so uh secondly the implementation is now completed meaning that the workarounds
Brian Okken: introduced in 3.13 make code sound without the gil are now gone, and free-threaded implementation
Brian Okken: now uses the adaptive interpreter as the gil-enabled variant. What does that mean? It means that the
Brian Okken: additional optimizations... Oh, okay. Also, those facts plus additional optimizations make the
Brian Okken: performance penalty that we had in 313 way better or way less annoying so in 313 the free thread if
Brian Okken: you're doing non-async code just straight code you had to face a like a 35 time penalty which sucks
Brian Okken: um now it's like a five to ten percent difference and i think it's going to shrink even more
Brian Okken: but um so if you're if you don't need the free threaded don't use it unless or or use it whatever
Brian Okken: But if it's time critical, don't right now.
Brian Okken: But I think it's going to get better.
Brian Okken: And especially if you are using async and stuff, it's way faster to use the free-threaded, of course.
Brian Okken: So this article does a shout-out to Miguel Grimberg's article about performance.
Brian Okken: I think we covered it last week.
We did. You did.
Brian Okken: No, maybe I did. We did. I can't remember who started it.
Brian Okken: So this article has a whole bunch more benchmarks.
Brian Okken: And I'm not going to walk through all of them, but talks about doing a service with JSON responses and both measuring with WSGI and ASCII implementations.
Brian Okken: And yes, talking about using Gradient.
Brian Okken: So that makes sense.
Brian Okken: So I'm going to jump down.
Brian Okken: So there's a bunch of metrics, but basically the end result is if you're using ASCII or ASGI, the free-threaded one is obviously the way to go.
Brian Okken: And you don't get really much of a hit because of free-threaded implementation at all.
Brian Okken: You get speedups and memory usage is reasonable.
Brian Okken: So what I want people to do, if you're going to check this out, is to jump down to the final thoughts because there's some great stuff here.
Brian Okken: Essentially, so what do I want to pick out?
Brian Okken: On asynchronous protocols like ASGI,
Brian Okken: despite the fact that concurrency model doesn't change that much,
Brian Okken: it's a shift from one event loop per process to one event loop per thread.
Brian Okken: I think that's a big change, actually.
Brian Okken: Just the fact that we no longer need to scale memory allocations
Brian Okken: just to use more CPU is a massive improvement.
Brian Okken: That's cool.
Brian Okken: Didn't know that.
Brian Okken: That's neat.
Brian Okken: For everybody out there coding a web application in Python,
Brian Okken: simplifying the concurrency paradigms
Brian Okken: and the deployment process of such applications
Brian Okken: is a good thing, obviously.
Brian Okken: And the conclusion being,
Brian Okken: for me, the future of Python web services
Brian Okken: looks like the Guilfri.
Brian Okken: So if you're doing web services,
Brian Okken: try out the free-threaded version.
Brian Okken: At least one developer there is completely happy
Brian Okken: with what we have now.
Michael Kennedy: Yeah, super nice.
Michael Kennedy: A bit of real-time follow-up.
Michael Kennedy: Yes, indeed. It is the same Giovanni.
Michael Kennedy: All right.
Michael Kennedy: Who creates a granion.
Michael Kennedy: So with any of these web production app servers
Michael Kennedy: where you run your Python code when it's running,
Michael Kennedy: whether it's Django, Flask, whatever,
Michael Kennedy: there's a process that runs your code.
Michael Kennedy: Very often, the way that we've got them to work around the gill,
Michael Kennedy: like in the web, the GIL is a much smaller problem.
Michael Kennedy: It's still a problem, but it's less.
Michael Kennedy: Because what we do often is we create a web garden.
Michael Kennedy: So when you set up gran, you can say,
Michael Kennedy: and start four copies of yourself.
Michael Kennedy: So that, yes, they all have the gil,
Michael Kennedy: but we'll round robin requests between the fours.
Michael Kennedy: If you've got four cores, four CPUs,
Michael Kennedy: you basically can say, well, each one of these
Michael Kennedy: is dedicated to a CPU and it can kind of like match, right?
Michael Kennedy: Yeah, so we're running on good stuff.
Michael Kennedy: But the thing is, when you have this free threaded option,
Michael Kennedy: you can actually have true concurrency in your one worker.
Michael Kennedy: So instead of scaling out four copies,
Michael Kennedy: you could have just one and just say,
Michael Kennedy: let that one take 10 concurrent requests
Michael Kennedy: or whatever it needs to take.
- Yeah.
Michael Kennedy: - Right, so that's how the free thread gets better.
Michael Kennedy: And like, well, okay, why?
Michael Kennedy: What's like six, one, half dozen, the other?
Michael Kennedy: No, the memory becomes a problem
Michael Kennedy: when you create these little web gardens
Michael Kennedy: because if normally your server would use half a gig
Michael Kennedy: and you create four, well now it's two gigs
Michael Kennedy: and maybe that bumps you up in another tier and so on, right?
Brian Okken: - Yeah, and if you need that memory for data,
Brian Okken: you don't have it, so.
Michael Kennedy: - Yeah, so I think that's kind of one of the angles
Michael Kennedy: your writing concurrent code, but the foundations of your code running can do so more efficiently
Michael Kennedy: because they're no longer needing to work around processes, limitations like, well, we got to
Michael Kennedy: fan out these processes because of the kill. Okay, back to the regular scheduled programming,
Michael Kennedy: free threaded Python, let's keep going. So here's an interesting article from a snake wearing a very
Michael Kennedy: fast, it's a very fast snake with jet engines that is wearing a garbage collector. So what I
Michael Kennedy: want to talk about is unlocking the performance in Python's free threaded future GC optimization.
Michael Kennedy: So garbage collection is not something that we frequently talk about a ton in Python. You know,
Michael Kennedy: it's just, we don't think a lot about GC. We don't think a lot about memory. I don't know why, like,
Michael Kennedy: as you know, Brian, in C, C++, people are like always about it, right? Like, oh my gosh,
Michael Kennedy: what size of point and what size of integer are we going to use for this, right? And like,
Michael Kennedy: it's just way more sort of in the forefront, but it's nice every now and then to peel back the
Michael Kennedy: and get a look at what's going on here.
Michael Kennedy: So Neil Schemenauer wrote this article over here from QuantSight.
Michael Kennedy: They do a bunch of data science primarily.
Michael Kennedy: But here, check this out.
Michael Kennedy: This is news to me, actually,
Michael Kennedy: even though I'm still interested in these things.
Michael Kennedy: It says, first, the most important thing to know
Michael Kennedy: is that free-threaded Python uses a different garbage collector
Michael Kennedy: than the default Python, the gil-enabled.
Michael Kennedy: The gilded, I still want to call it the gilded Python.
Michael Kennedy: The gilded Python.
Michael Kennedy: So we have the default GC,
Michael Kennedy: which people probably understand pretty well.
Michael Kennedy: When you create a number, like a thousand,
Michael Kennedy: when you create a list,
Michael Kennedy: when you create an object from a class,
Michael Kennedy: all of those things have a data structure at the top of them
Michael Kennedy: that allows them to manage and track the memory.
Michael Kennedy: And people think of the GIL as being a threading thing.
Michael Kennedy: The GIL is really a protection mechanism
Michael Kennedy: for memory management in Python, right?
Michael Kennedy: It's basically protection against a race condition
Michael Kennedy: in the reference counting.
Michael Kennedy: So basically interacting with this structure
Michael Kennedy: that has seven things reference me
Michael Kennedy: and I reference it, however, you know what I mean?
Michael Kennedy: Like that sort of deal.
Michael Kennedy: - Yeah.
Michael Kennedy: - And when the thing goes out of scope,
Michael Kennedy: it decrements that and that's where the GIL comes in
Michael Kennedy: to like make that decrement safe and so on.
Michael Kennedy: So that's the regular one,
Michael Kennedy: but we don't even have that structure anymore
Michael Kennedy: in the free threaded one.
Michael Kennedy: So what?
Michael Kennedy: So instead, when you allocate stuff,
Michael Kennedy: it goes into a special memory managed heap called memalloc,
Michael Kennedy: or managed by memalloc, right?
Michael Kennedy: And this allows the GC to loop over all these objects
Michael Kennedy: and figure out which ones are junk and which ones aren't.
Michael Kennedy: A little bit like a mark and sweep garbage collector.
Michael Kennedy: So there's a couple of interesting things.
Michael Kennedy: One is that most of the mark and sweep garbage collectors
Michael Kennedy: and that type of thing, they have generations,
Michael Kennedy: like a generational one.
Michael Kennedy: So it has Gen 0s where most objects come,
Michael Kennedy: then it'll check that frequently and so on.
Michael Kennedy: That's also how the garbage collector that looks for cycles
Michael Kennedy: in the regular Python goes, right?
Michael Kennedy: But it doesn't work here because of unmanaged C extensions
Michael Kennedy: and a bunch of stuff like that.
Michael Kennedy: So what it does is it can mark all the objects reachable
Michael Kennedy: from what it calls known roots.
Michael Kennedy: So instead of trying to scan the entire memory space,
Michael Kennedy: it says, well, what are globals?
Michael Kennedy: What are locals?
Michael Kennedy: what are like a you know it sort of follow those and it marks those as active and that can they can
Michael Kennedy: automatically be excluded from the search which is kind of like a generational optimization so
Michael Kennedy: pretty interesting but here's the takeaway we were talking about making things faster by using free
Michael Kennedy: threaded python with this one it's the free threaded gc collection is between two to 12 times faster
than the 3.13 version wow that's pretty yeah that's pretty wild right yeah yeah so depending on how
Michael Kennedy: your algorithms work,
Michael Kennedy: do you have a super pointer,
Michael Kennedy: pointer,
Michael Kennedy: heavy allocation,
Michael Kennedy: heavy type of algorithm,
Michael Kennedy: then,
Michael Kennedy: you know,
Michael Kennedy: we'll probably see a bigger benefit
Michael Kennedy: than if you allocate a few things
Michael Kennedy: and jam on those.
Michael Kennedy: So anyway,
Michael Kennedy: if you want to peel back the covers
Michael Kennedy: and see the GC,
Michael Kennedy: I didn't even know they were different,
Michael Kennedy: but apparently they're different.
Michael Kennedy: And presumably,
Michael Kennedy: maybe they could even have
Michael Kennedy: like multi-threaded GC stuff going on.
Michael Kennedy: That might be cool.
Michael Kennedy: Or background thread GC.
Michael Kennedy: I know those are a lot of different things
Michael Kennedy: that happen in some of these systems.
Michael Kennedy: These garbage-coach systems.
Michael Kennedy: Yeah.
Michael Kennedy: And finally,
Michael Kennedy: A little bit of real time, not quite real time, but real world follow up, I'll say.
Michael Kennedy: So for some reason, I can't remember what I was doing.
Michael Kennedy: Something I had to do, I had to go back, go through all the examples of my async programming course at Talk Python.
Michael Kennedy: So I went back in there and I said, all right, well, let me just make sure everything's running, update all the dependencies.
Michael Kennedy: I can't remember what it was.
Michael Kennedy: But anyway, something had to be updated.
Michael Kennedy: So I made sure all the dependencies got updated and pinned them to newer ones.
Michael Kennedy: And I'm like, well, there's a lot of changes here.
Michael Kennedy: Let me make sure they're all running.
Michael Kennedy: So go around and I ran every example from the course, probably 25 little apps.
Michael Kennedy: And many of them are like, well, here's a web app, or here's just a way to do
Michael Kennedy: multiprocessing, have a look at it.
Michael Kennedy: But a lot of them were like, let's actually do this with threads.
Michael Kennedy: And in this example with doing IO, you see it does make a difference.
Michael Kennedy: In this example doing computational stuff, no difference or slower because there's
Michael Kennedy: just overhead and it's still running one at a time, right?
Michael Kennedy: Well, I decided to type uv-python 3.14t run those examples and run them free threaded.
Michael Kennedy: The ones that used to have no benefit or a net negative are now like seven times faster.
Michael Kennedy: It would go like synchronous one, 10.2 seconds.
Michael Kennedy: Async or threaded one rather, 10.25 seconds.
Michael Kennedy: And now just put the T on the end, three seconds.
Michael Kennedy: that's pretty cool that is pretty cool man so to me it's really down to what are the framework
Michael Kennedy: what are the packages and libraries that you're using if it's green across the board for free
Brian Okken: threaded that's pretty interesting it opens up some real possibilities yeah also i i think i'll
Brian Okken: be looking forward to the i know i don't know if we have a deadline or timeline for this but
Brian Okken: when we can go back to having one version of Python
Brian Okken: and it's being the free-threaded one,
Brian Okken: it'll be, you know, maybe we can switch it
Brian Okken: to be the default is the free-threaded one.
Brian Okken: And for a couple of versions, there's the other one also.
Brian Okken: You got to say 3.14G.
Brian Okken: Yeah, or something like that.
Brian Okken: And I think that would be good
Brian Okken: because the default way we think about how to program
Brian Okken: and how to program quickly
Brian Okken: And the rules of thumb based on the GIL will be gone.
Brian Okken: So we'll teach people different.
Brian Okken: Yeah.
Brian Okken: So anyway.
Brian Okken: Yeah.
Michael Kennedy: And before we move on real quick, a follow-up to your topic from chart here.
Michael Kennedy: Also, if you're on a Kubernetes, if you're on Kubernetes,
Michael Kennedy: it makes setting reasonable CPU and memory requests more difficult
Michael Kennedy: to have to scale out like the WebGarden type stuff.
Oh, okay.
Michael Kennedy: Yeah.
Michael Kennedy: So if you can just have one process like this is the one,
Michael Kennedy: I think it's easier.
Michael Kennedy: I believe that's what he was getting at.
Brian Okken: Yeah.
Brian Okken: And also, I mean, from the C++ world, yes, processes and threads both can work.
Brian Okken: But thinking in threads is easier than thinking about multiprocesses.
Michael Kennedy: 100%.
Michael Kennedy: Because you have shared memory.
It just is.
Michael Kennedy: You don't have to proxy stuff over and figure out how to sync it back up and copy it.
Brian Okken: To queues and all sorts of...
Michael Kennedy: Anyway.
Michael Kennedy: Okay.
Michael Kennedy: I can't resist.
Michael Kennedy: I got to say, I got to put this out there in the world and see what you think.
Michael Kennedy: One thing right now, we have the gilded Python and we have the free threaded Python.
Michael Kennedy: And I can choose to run the free threaded one, as we've been talking about, if I want that.
Michael Kennedy: But what about this, Brian?
Michael Kennedy: This is what I want to put out in the world.
Michael Kennedy: I want, like right now, if I have a project and I've got some data and I need to process
Michael Kennedy: this in parallel on the gilded one, I need to maybe do multi-processing.
Michael Kennedy: So that's going to spin up five little baby Python processes all to go jam on that, right?
That's how you get around the GIL.
Michael Kennedy: What about this?
Michael Kennedy: what if you could pass a flag to multi-processing
Michael Kennedy: and it would start up free-threaded Python with threads
Michael Kennedy: instead of a bunch of different processes
Michael Kennedy: that can't coordinate on whatever algorithm
Michael Kennedy: that you just say run multi-processing,
Michael Kennedy: but this time do it in free-threaded Python
Michael Kennedy: as your little multi-process burst
Michael Kennedy: and then come back to me with the answer.
Michael Kennedy: That would be cool.
Brian Okken: - Yeah, yeah.
Michael Kennedy: - You're not convinced?
Michael Kennedy: I mean, you could that way,
Brian Okken: 'cause you weren't right. - I mean, your code
Brian Okken: has to be different though.
Michael Kennedy: - Just that one function though.
Brian Okken: And you don't have to pay, you know what I mean?
Michael Kennedy: like this one function that i'm going to call multi-processing on i'm going to write it assuming
Michael Kennedy: that it can be it will be an advantage to be threaded or it will be an advantage to be concurrent
Michael Kennedy: but the rest of my code i don't have to rewrite like it'd be a cool way to sort of bring kind of
Michael Kennedy: like scython lets you bring and say this one function if just this were way faster it would
Michael Kennedy: make all the difference you could do that but for free threading i would like to see that would be
Brian Okken: interesting yeah yeah or just a chunk to say like yeah this um this subsystem is a through with
Michael Kennedy: With free threading.
Brian Okken: All right, go ahead.
Brian Okken: Okay, completely different tangent is we're going to go back in time by a couple of one or two episodes.
Brian Okken: We've been, the last few episodes or two or three talking about lazy imports because I thought they were coming in 315.
Brian Okken: They're proposed in 315, but they're not here.
Brian Okken: So, or they're not accepted yet.
Brian Okken: I haven't checked.
Brian Okken: I don't think that anything's changed.
Brian Okken: So last episode, I did talk about lazy imports that you can use today.
Brian Okken: Responding to that, Bob Bilderbos had a discussion on LinkedIn.
Brian Okken: And part of that discussion, we had Will McCoogan hop in and said that he's excited about the PEP
Brian Okken: and that he has a lazy loading mechanism for textuals widgets, which totally makes sense.
Brian Okken: like widgets, you might just need a button, but you don't need all of the other widgets.
Brian Okken: Be cool if you could just load what you needed.
Brian Okken: And he's got that.
Brian Okken: So I checked it out.
Brian Okken: I was checking this out.
Brian Okken: And I think this is sort of a small topic, but I think it's cool.
Brian Okken: So the idea that I want to highlight is I presented last week a method for doing lazy
Brian Okken: loading now or lazy importing now on things that you depend on.
Michael Kennedy: But what if you're like, you don't have to wait.
Michael Kennedy: You can be lazy today.
Brian Okken: But what about like, yeah, exactly.
Brian Okken: What about if you're the package?
Brian Okken: If you have a big package that you have a bunch of stuff that people might want to import,
Brian Okken: making it so that you're not the problem, that your package is going to import really fast
Brian Okken: because behind the scenes, you're doing lazy importing for people.
Brian Okken: And that's essentially what Textual does.
Brian Okken: And the implementation is like really easy.
Brian Okken: So he's using a, basically, when you access anything, he's overriding the git adder function.
Brian Okken: So if you access a widget, it's going to try to just grab it out of a dictionary.
Brian Okken: And of course, right away, it's going to fail.
Brian Okken: And then if it fails, he goes ahead and imports it and then stores it in.
Brian Okken: So the next time somebody tries to grab it, it's going to be there.
Brian Okken: And so there's a little bit of misdirection here.
Brian Okken: But in the end, you get lazy loading on every widget access.
Brian Okken: So pretty cool.
Brian Okken: And so I thought, you know, this is pretty neat.
Brian Okken: I don't want it just to be hidden.
Brian Okken: It's not hidden.
Brian Okken: It's an open source project.
Brian Okken: So I went ahead and wrote all this up in a new post called Polite Lazy Imports for Python Package Maintainers.
Very nice.
Brian Okken: link to that also but i just thought that the implementation is totally clever and um and maybe
Brian Okken: it's maybe for other package maintainers this is like well yeah that's the way you do it but um it
Brian Okken: was new to me i thought it was neat so there we go also want to shout out i didn't realize there
Brian Okken: was both git adder git adder is used for uh for if it's not found for missing items but also there's
Brian Okken: another one called get attribute. And I did look up, I really appreciate that Trey Hunter had posted
Brian Okken: this every Dunder method article. So pretty cool. I totally have this bookmarked so that I'm like,
Brian Okken: if I want to understand the Dunder method in Python, I go here.
Michael Kennedy: Yeah, very cool. I know it for classes, but for modules as well. Interesting.
Brian Okken: Yeah, I don't think, and packages. So this is, you go ahead and throw it. Well, I guess,
Brian Okken: It is for modules, but if you put that in a dendronit file,
Brian Okken: then it's for your entire package.
Brian Okken: Yeah, exactly.
Brian Okken: It's pretty cool.
Michael Kennedy: I love it.
Michael Kennedy: Nice.
Michael Kennedy: All right.
Michael Kennedy: Is that all your extras?
Michael Kennedy: Oh, that's just...
Michael Kennedy: Your main thing.
Michael Kennedy: That's my main thing.
Michael Kennedy: What do you got for extras?
Michael Kennedy: I do have one extra.
Brian Okken: The one extra, so one of the things I've been doing is I've been,
Brian Okken: you know, I paused Python people a long time ago,
Brian Okken: And I totally stopped doing testing code.
Brian Okken: I'm focused on this too and focused on work, but I'm also writing more.
Brian Okken: And one of the things I'm doing is writing a book on test driven development.
Brian Okken: And I don't have an announcement yet, but in the next couple of weeks, I think I might
Brian Okken: have an announcement.
Brian Okken: But if you'd like to know what, I guess what I'm going to do is I'm going to write it.
Brian Okken: I'm going to write the book, but to motivate me and to make people not have to wait.
Brian Okken: I'm doing it as a, like a, you know, like Manning does like the early access books and
Brian Okken: Pragmatic has beta books.
Brian Okken: I'm kind of doing that.
Brian Okken: I'm doing a lean, trying to do a lean startup applied to books.
Brian Okken: And I'm going to release it after I've got, I'm like, you know, do a rough first draft,
Brian Okken: clean it up a little bit and then release it for every chapter.
Brian Okken: And then as I go along, incorporate feedback from people.
Brian Okken: And then once the whole thing is good and polished, I might bring on an editor or something
Brian Okken: or maybe just release it.
Brian Okken: But if you'd like to know more about that,
Brian Okken: I'll announce it here.
Brian Okken: But also, if you'd like to know the minute it's available,
Brian Okken: join the newsletter over at Python Test,
Brian Okken: and I'll let you know.
Michael Kennedy: Yeah, we really do appreciate when you join our newsletter.
Michael Kennedy: You might think, oh, we can just announce these things
Michael Kennedy: on social media or on the podcast,
Michael Kennedy: but it's not the same people.
Michael Kennedy: A lot of people miss it because they miss an episode,
Michael Kennedy: or social media is just a screaming feed of stuff.
Michael Kennedy: It really makes a difference.
Michael Kennedy: So join the newsletter.
Brian Okken: Also, I want to talk about there's newsletters and then there's newsletters.
Brian Okken: So this isn't really – I don't do a weekly eight tips on testing.
Brian Okken: That would be cool.
Brian Okken: I just don't have time to do that.
Brian Okken: So it's mostly announcements if there's something to keep track of.
Brian Okken: But people like you and me and others, we're using things like – I'm using Kit, but there's others.
Brian Okken: I've used other email things before.
Brian Okken: I don't keep track of who's subscribed.
Brian Okken: So I'm not going to sell this to anybody or anything.
Brian Okken: It's just an announcement thing.
Brian Okken: And you can unsubscribe anytime.
Brian Okken: And I don't even know.
Brian Okken: Like once you're unsubscribed, you're gone.
Brian Okken: I don't have the access to that.
Brian Okken: So there's people that abuse newsletters and people that I don't think there's a lot of people in the Python tech space that do, though.
Brian Okken: So it's not spammy.
Brian Okken: Anyway, moving on.
Brian Okken: Do you have any extras for us?
Michael Kennedy: I actually have a couple.
Michael Kennedy: Let's jump over and hear about it.
Michael Kennedy: Very exciting news.
Michael Kennedy: I am really happy with this new course that I created called
Michael Kennedy: Agentic AI Programming for Python Devs and Data Scientists.
Cool.
Michael Kennedy: Yeah, and the idea is basically, so we have these agentic AI tools
Michael Kennedy: like Claude Code and Cursor and Juni and all of them,
Michael Kennedy: but how do you actually be successful with them, right?
Michael Kennedy: I've talked a few times about just insane productivity
Michael Kennedy: and really good outcomes that I've had,
Michael Kennedy: and people are like, how are you doing that?
Michael Kennedy: So this course is like a real world set of guidelines and examples and best practices
Michael Kennedy: for working with agentic AI.
Michael Kennedy: So build, spend an hour building like a really detailed application.
Michael Kennedy: But we also, it also talks like almost for an hour about like guardrails and roadmaps
Michael Kennedy: and how do you get it to do exactly what you want.
Michael Kennedy: You're like, when I say build an app, don't just build the app, but build it with uv,
Michael Kennedy: write high test tests, format it with rough, with this Tommel.
You don't have to do any, you don't have to, but you know, like how do you get it to give
Michael Kennedy: you what you want?
Michael Kennedy: Not something in the vague general space of what you asked for.
Michael Kennedy: You know what I mean?
Michael Kennedy: So sort of a practical agentic AI programming course.
Michael Kennedy: So I really, I'm getting like crazy amounts of good feedback on this course.
Michael Kennedy: So people check it out.
Michael Kennedy: The link is in the, in the show notes.
Michael Kennedy: I think it's talkpython.fm dash slash agentic dash AI.
Michael Kennedy: So that one's fun.
Michael Kennedy: What else?
Michael Kennedy: I'm also going to be on talking with Hugo Bowen Anderson.
Michael Kennedy: He's running the Vanishing Gradients podcast.
Michael Kennedy: He was on Talk Python a while ago,
Michael Kennedy: and now I'm going to be on his show,
Michael Kennedy: Data Science Meets Agentec AI.
Michael Kennedy: Sort of a follow-up from my Talk Python in production book,
Michael Kennedy: plus this course I just talked about.
Michael Kennedy: Those are those kind of ideas.
Michael Kennedy: We're going to spend some time riffing on that.
Michael Kennedy: So that's tomorrow night US time.
Michael Kennedy: So check that out.
Michael Kennedy: All right. Also, OpenAI introduced
Michael Kennedy: an AI browser wrapping Google Chrome called Atlas.
Michael Kennedy: This is interesting.
Michael Kennedy: I played with it.
Michael Kennedy: I'm not convinced yet.
Michael Kennedy: I mean, it's kind of fine.
Michael Kennedy: I don't know.
Michael Kennedy: I don't even know what to think about these things.
Michael Kennedy: That's not why I included it.
Michael Kennedy: Maybe it's sort of interesting as a side note.
Michael Kennedy: But I linked to the Ars Technica article.
Michael Kennedy: Holy smokes, you guys.
Michael Kennedy: Check out the comments.
Michael Kennedy: They are not loving it.
Michael Kennedy: And it's not OpenAI's fault exactly.
Michael Kennedy: It's just this idea of AI taking over everything is not.
Michael Kennedy: At least if there's not everyone hating on it,
Michael Kennedy: there's a very vocal group of people who don't love it.
Michael Kennedy: So, and I just noticed that Kyle Orland wrote this
Michael Kennedy: and he actually wrote a whole book on Minesweeper,
Michael Kennedy: which, you know, props to him for that.
Brian Okken: But check out the- - Oh, that's awesome.
Brian Okken: I gotta check that out.
Michael Kennedy: - I'm like, geez, it's been a long time
Michael Kennedy: to thought about Minesweeper.
Michael Kennedy: Anyway, this is actually just a really interesting
Michael Kennedy: cultural like touch point, I think.
Michael Kennedy: So people can check that out.
Michael Kennedy: All right, James Abel, one of the,
Michael Kennedy: I think he was behind Pi Bay this year, but yeah.
Michael Kennedy: In the San Francisco area said,
Michael Kennedy: Hey, we somehow we were talking about dunder name.
Michael Kennedy: If dunder name equals dunder main today, I have a package.
Michael Kennedy: It's real, real simple.
Michael Kennedy: But instead of writing this, if you want to like get people started, you can just
Michael Kennedy: import my thing and say, if is main as a simpler, saner way, it should, that maybe
Michael Kennedy: should be a built in, don't you think?
Michael Kennedy: Python.
Yeah.
Or what I would rather see is if isn't main, here's what I would like to see, but
Michael Kennedy: I don't know that Python has a mechanism for it.
Michael Kennedy: I would like to say at the top, something to the effect of register this function as
me, and then when it's done parsing the file, then it runs it because even this,
Michael Kennedy: which is super helpful, it's still, if you accidentally put code below it, it's a
Michael Kennedy: problem, you know what I mean?
Michael Kennedy: I would like Python to enforce, like we'd load the whole file and then it runs
Michael Kennedy: like a cool mechanism for that.
Michael Kennedy: But still, this is pretty nice.
Michael Kennedy: And at first I thought I was just like wrapping if name is main, right?
Michael Kennedy: But in fact, it's like doing some a little bit different here.
Michael Kennedy: It's using the inspect stack to go back and then look at the value.
Michael Kennedy: Because obviously, it itself is not main, so it can't do that test.
Michael Kennedy: So I don't know, kind of cute.
Michael Kennedy: Yeah.
Michael Kennedy: If you don't want to have a dependency on this library,
Michael Kennedy: you could take that line of code and put it somewhere as a utility class in yours.
Brian Okken: But, okay, I'm just going to throw this out there.
Brian Okken: If you want to do something really fast, make sure you time this.
Brian Okken: Because every time I've added inspect, I love the inspect library.
Brian Okken: But whenever I add it, it slows things down.
Brian Okken: Okay.
Brian Okken: Just benchmark.
Brian Okken: Benchmark it.
Brian Okken: All right.
Brian Okken: Benchmark it.
Michael Kennedy: All right.
Michael Kennedy: Inline.
Michael Kennedy: All right.
Michael Kennedy: If you're an IntelliJ person like PyCharm, wouldn't it be nice, Brian?
Michael Kennedy: Wouldn't it be incredible if while you're working, a little pet could walk around in the bottom?
Michael Kennedy: Anthony Shaw, I believe, is the one who added this to VS Code.
Michael Kennedy: Yeah.
Michael Kennedy: PyCharm people can love animals too.
Michael Kennedy: So you could install the pet into your PyCharm now.
Michael Kennedy: Oh, cool.
Michael Kennedy: Nice.
Michael Kennedy: I don't know that I'm going to be doing it.
Michael Kennedy: This is a last minute edition.
Michael Kennedy: I just got a brand new M5 iPad.
Michael Kennedy: How insane is that?
Michael Kennedy: I've had the last one I had, I got five years ago.
Michael Kennedy: I'm like, it's probably time.
Michael Kennedy: And I got a 13-inch iPad Pro, which is an insanely large iPad.
Michael Kennedy: But I started using it as the second monitor for my laptop.
Michael Kennedy: if I'm traveling or if I'm at a coffee shop or something.
Michael Kennedy: And that's a super cool experience.
Michael Kennedy: Just put them side by side.
Michael Kennedy: If they're on the same network or the cable,
Michael Kennedy: they just do real, real low latency, dual monitor stuff.
Michael Kennedy: And yeah, it's pretty neat.
Brian Okken: So just a little shout out to that.
Brian Okken: That's incredible.
Brian Okken: It's like having a new laptop, a second laptop
Brian Okken: for the price of a second laptop.
Michael Kennedy: Yes, it is.
Michael Kennedy: But here's the thing.
Michael Kennedy: Yes, I agree.
Michael Kennedy: But it's also a really nice reading device,
Michael Kennedy: which I do a lot of reading and stuff.
And I was going to get one of the cheaper ones.
Michael Kennedy: One of the things that drives me, I have a MacBook Air as my main laptop computer and
Michael Kennedy: the same chip for my main computer.
Michael Kennedy: I don't have a high end computer and it's plenty good for Docker stuff or programming
Michael Kennedy: stuff, all these things.
Michael Kennedy: It's totally fine.
Michael Kennedy: But here's the thing.
Michael Kennedy: The iPad Air, while great, it's peak brightness is something like five or 600 nits.
Michael Kennedy: And if you're working, like I like to work in my back outside area in the summer, like
Michael Kennedy: that's kind of not relevant right now.
Michael Kennedy: But in general, you know, sit outside, enjoy the weather, get out of the office.
Michael Kennedy: And if it's at all bright through a window or somewhere, it's like really a pain.
Michael Kennedy: This thing is like the best screen you can buy on a Mac, period, whatever.
Michael Kennedy: And it's a thousand nits.
Michael Kennedy: So you could push the computer to the side and just put the laptop in front of you and
Michael Kennedy: type on it.
Michael Kennedy: It's really nice.
Michael Kennedy: Anyway, that's the main reason.
Michael Kennedy: I want a brighter screen without having a MacBook Pro.
Brian Okken: I feel so bad for you having to deal with like working outside in such bright light.
Michael Kennedy: It's really horrible.
Michael Kennedy: I know.
Michael Kennedy: You should really.
Michael Kennedy: It's hard.
Michael Kennedy: It's hard doing me.
Brian Okken: All right.
Michael Kennedy: Carrying on with the jokes.
Michael Kennedy: No, go ahead.
Brian Okken: Well, before we get to the joke, I wanted to, I guess, highlight, going back to my announcement
Brian Okken: of possibly a book.
Brian Okken: Japanol7 says, a TDD book by Brian.
Brian Okken: Can't wait.
Brian Okken: Also, Talk Python training courses are great.
Brian Okken: Kudos.
Brian Okken: Yeah.
Brian Okken: I'm awesome.
Brian Okken: Yeah.
Brian Okken: I'm looking forward to getting that book out, and I'm looking forward to that AI course
Brian Okken: of yours.
Michael Kennedy: Yeah, same.
Brian Okken: All right.
Michael Kennedy: I'm not looking forward to surgery, I'll tell you what.
Michael Kennedy: And it's getting to be weird, Brian.
Michael Kennedy: I mean, like doctors using AI and stuff.
Michael Kennedy: Actually, we probably are going to get better diagnoses as for certain things.
Oh, dear.
Michael Kennedy: But here's a surgeon situation.
Michael Kennedy: There's a person who just, they're in post-op, okay?
Michael Kennedy: They're laying there like, oh, man, a little woozy from the anesthesia coming out of it.
Michael Kennedy: And the doctor, which is a robot with a ChatGPT-like, I don't think it's, is it the same?
Michael Kennedy: know something an ai logo for a robot face and the patient says but why is the scar on the left
Michael Kennedy: if the appendix is on the right the ai surgeon says you're absolutely right let me try that one
Michael Kennedy: more time please don't try it one more time it's so bad it's pretty bad it's pretty funny that
Brian Okken: actually drives me nuts when when i'm like this doesn't sound right is this you know
Michael Kennedy: The user is pointing out I've made a mistake.
Brian Okken: Oh, you're right.
Brian Okken: Yeah.
Brian Okken: Oh, well.
Brian Okken: Yeah.
Michael Kennedy: So, yeah, just get a second opinion.
Michael Kennedy: So if opening is going to operate on you,
Michael Kennedy: have Anthropic be the backup, I guess, is the moral of the story.
Michael Kennedy: I don't know.
Brian Okken: I don't think that's the moral of the story.
Michael Kennedy: You don't think so?
Michael Kennedy: Okay.
Brian Okken: Maybe somebody trained in medicine.
Michael Kennedy: Trained on medicine?
Michael Kennedy: I'm sure they are.
Brian Okken: Trained with heavy medication.
Michael Kennedy: Yeah, exactly.
Brian Okken: All right, cool.
Michael Kennedy: Well, fun as always.
Brian Okken: Well, definitely fun as always.
Brian Okken: And we'll see everybody next week.