- Podcasts
- Python Bytes
- #479 Talking About Types
About this episodeTopics covered in this episode: httpxyz one month in Learn concurrency - a deep dive into multithreading with Python pip 26.1 - lockfiles…
- httpxyz one month in
- Learn concurrency - a deep dive into multithreading with Python
- pip 26.1 - lockfiles and dependency cooldowns
- Python 3.15 sentinal values from PEP 661
- Extras
- Joke
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
#479 Talking About Types
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to earbuds. This is episode 479, recorded May 11th, 2026. And I'm Brian Aachen. And I'm Michael Kennedy. This episode is sponsored by all of our stuff, like the pytest book and pytest courses and Talk Python training and so much else.
And also Patreon supporters. Thank you, Patreon supporters. If you'd like to get a topic, if you've got a topic that you think we ought to talk about or just are interested in, don't worry about whether or not we've heard it or not. Just send it on over anyway. You can reach us on Mastodon and Bluesky.
And there's a contact form right on the show notes, but right there on pythonbytes.fm as well. So you can check that out. Thanks to everybody that watches us live on YouTube. If you'd like to be a part of the audience and submit comments and stuff, you can head on over to pythonbytes.fm/live and be part of that.
This is, okay, this is the thing that really made me want to cover this because they released a compatibility shim that allows you to use HTTPX YZ even when third-party packages use HTTPX themselves. So this is my dilemma. I look at my project and I see that I'm using HTTPX and I'm like, huh, it'd be really cool to switch to HTTPX YZ.
Seems like the right thing to do. And then I go look at my pip compiled output and it says HTTPX because these seven packages are using HTTPX. I'm like, huh, well, that's kind of useless. Like why would I use one when I have to effectively use these others all the time when I interact with those libraries, right?
I'm still in the same boat and I don't see a life raft or any way to get out of that boat. But here's that thing. And it's pretty interesting. If all you got to do is if you import at the startup of your app HTTPX YZ, it also tells it the world that it is HTTPX. Okay. So for example, you can assert that HTTPX is in system modules of HTTPX YZ, right?
That kind of thing. So if you import HTTPX somewhere along the way, some other app does, other part of your app does, it will still, it'll still return basically a compatible layer, even at a type instance. So if you ask, is this thing that I got from HTTPX YZ.response of some type of, is that actually an HTTPX.response?
Yes. So really interesting compatibility. And honestly, I don't know how it does that. That's pretty interesting. Yeah. How do you say you are, I derive from this class in another library without having the other library present? You know what I mean? Well, as long as the endpoints are there, you're going to fulfill it.
So this is not uncommon, like Pillow has done this, OpenCV has done this, YAML, PyYAML have done this, and so on. Well, but done this being, they've got a different name that you use, you import from the library. But the hijacking some other project's name, that's, I don't know what I feel about that.
I don't know a way around it other than this. No, in this case, I think it's a good thing. It seems like this could be abused. Yes. Agreed. Agreed. Okay. Well, welcome to Python imports, I guess, huh? Yeah. So I think this is actually pretty interesting. And also, this is kind of the flow of this project.
It's like, oh, we noticed that HTTP core is actually the root of many of the problems, which is also a similar project. So we have to create HTTP core XYZ, and fix a whole bunch of issues, some serious, and so on. So there you go. Got some nice quotes here. And then finally, it's on Codeberg, which I think is not the right choice.
I understand the desire, but in practice, I don't think it's the right. I think it should be on GitHub, even with all the GitHub issues. Because, you know, you look at it, it's got 39 stars. Like, HTTPX has 15,000. Right. So on GitHub. I don't know. I think that that's, you know, Mikhail says, look, I'd love to make GitHub a little bit less dominant.
Are you optimizing for the developers, the project's benefit? Or are you optimizing for exposure? I don't think so. I think it's whether or not you want contributors. Because the exposure's through, like, PyPI, not really GitHub. And maybe podcasts, people talk about it. Yeah. Anyway, I think it's a cool project.
It's on GeekUni. I don't know what that is. But it looks like there's some interesting stuff way back to 2013. But anyway, Lean Concurrency, a deep dive into multithreading with Python. And this is the author, Nikos. And I actually really like this article. So I do. I'm familiar with multithreading in multiple languages.
And I don't use it a lot in Python. And I do have a lot of projects or at least a couple of projects coming up that I want to use some concurrency. And so a refresher is a good idea. And the world has changed a little bit recently. I mean, the big recently in Python because we've got Gilders Python.
We probably should know that. But things like global interpreter lock. And, you know, I guess we already know those things. But there's a... One of the terms is like embarrassingly concurrent. And I kind of forgot what that meant. So it's good there. And that just means... Well, it means that you can separate the work into things that can work without any interactions.
Those are embarrassingly concurrent. Anyway. Yeah. One super, super common example of that is like video game graphics. Each pixel is computed independent of each other pixel. So if you've got a million pixels, like as much parallelism as you can just compute each pixel at the same time, they're not going to interfere with each other, right?
Yeah. It is funny that it's embarrassingly. It's not really embarrassingly. It's just ideal. Exactly. What a glass half empty perspective that is. So I just encourage people to look through this. There's some great walkthroughs about different things. And also, it talks about free-threaded concurrency as well.
So it's slightly interesting with a Fibonacci. But how many times do you really calculate Fibonacci? So the better examples below that. And it's a very simple example of just having a bunch of threads update a counter. But it's... And you won't do this. But it'll be... It's a cool example because it's an obvious one where you've got shared data.
There are a bunch of threads all accessing the counter. So it's a very simple toy example. But you could see how that relates to a lot of other work. The cool thing... One of the interesting things about this is it talks about some of the problems with concurrency, how to get around it, problems with concurrency and shared data.
And one of the first things I reached for because I came from C and C++ is locks when I want to have shared data. And within this example, locks turns out to be the wrong solution because it actually slows everything down. And I'm familiar with that with other languages as well. But the cool thing that I've never really understood before that I'm grateful for this article to talk about is the thread pool executor.
So anyway, good article. It's very exciting. Good introduction. Yeah, cool. And it's very exciting. I think it's going to give us a chance to talk about all sorts of fun things. You know, we in Python land have not obsessed about all these design patterns, race conditions, making sure you lock all of your activity.
So. Yeah, yeah, I know. But like, that's totally fine for one operation. But let's suppose that I like, you know, the classic bank example. I take, I debit somebody out of this account. I do 10 lines of work. And then I credit the other account. Yeah. Nothing, nothing says that the guild will not stop halfway through.
It's just, it's not very likely. So the, you know, those problems are there in the code, which I think is going to be a double whammy. But it also lets us start to think about the fun things like double checked locking, which is such a cool idea. You know, like, there's, there's, I think it's going to be really fun.
I think it's going to be fun. So for example. Checked locking. Yeah. So check this out. So I, I'll put this in the show notes. It's just off of, or put it, look it up on Wikipedia. So what you can do is you can say, if you have a single threaded thing, you can check, like, if this, this object is null.
But you can do things like check outside the lock if it's null and then take a lock and then check again if it's null. Because maybe two things hit, one of them locked, one of them created it. You still want the same one. But you can like skip the locking ever, except for like during the once, one and only creation.
Like there's really fun patterns like that. So I'm kind of actually looking forward to it, you know? I'm not looking forward to the race conditions. Yeah, yeah, yeah, yeah. Speaking of locks, let's lock files instead of memory and execution. So it turns out that pip 26.1 is out. And it comes with features that I've been very excited about.
Most importantly, dependency cooldowns. Don't remember, I don't remember when I wrote about this. It was December last year. I wrote about Python supply chains made easy. And I wrote a follow-up one for like doing that production. One of the really most important significant bits of this was, you know, instead of you finding out, let's let others find out that something's bad.
They have different CLI flags, which I don't know. I feel like they should have just said, well, what are people using now? Let's use that same CLI flag. But so it is. So it has this. Let's go down to the cooldowns. Here we go. So you can say --uploaded prior to. And you can put some kind of time in there, a duration.
So PND, where N is the number of days, kind of. Okay. Anyway, so you say P3D is like prior to three days is the value. And then you can install something. And that says it will only install the older, you know, stuff older than three days. And this is super valuable. It sounds like, oh, Michael, this is like security through obscurity.
Just install a different version of Pip. I think that's like a no-brainer and should just be like a default. New features. This is interesting. Like, first of all, I am very positive about this. I think this is a great move and I'm really happy to see it. Even if I have some criticisms like PND, which is just weird.
Yeah, I got it. So there's this PEP 751, which was created 2024. And it was, I believe it was accepted 14 months ago. I'm not entirely sure. It's not super obvious, but the resolution is March 2025. So it's been around for a long time, about a year plus. Okay. And this is the file format to record Python dependencies for installation reproducibility by Brett Cannon.
Oh. Oh. Somewhat as an experimental feature. So a year after its acceptance, which standardized pylock.toml, pip 26.1 gains experimental support for such files, for reading and installing from them. Okay. So this is great. I think it's just, you know, pip is the most common way to install stuff in Python still, even if it's not the most hyped or most Rust implemented way to do it.
It's still the most common way. Right. And so having this support is kind of like table stakes. Right. So I think this is really cool. There's a bunch of caveats and limitations and so on and so on. But the criticism is like, if this is officially accepted by the core developers and Python and the steering council, why did it take a year for pip to support it?
You know, that seems pretty out of sync. That's a long time from, yeah, we have this official feature and our official installer can't use it. Yeah. But I'm glad that it has it. So that's good. Maybe there's more to it than I know again, but who knows. Some stuff about the older, like newer and older resolvers.
So, we're going to stick with the PEP thing for a little bit. this time Sentinel Values and also a blast from the past because, my search still up. Anyway, this, Sentinel Values is PEP 661 and it was created in 2021 and it's five years later. so it's taken a while. However, it is, resolved as of, and, and final as of, for, for five, on 315.
So we'll get, we'll get Sentinels finally. there's a, there's, the, the, PEP 661 has a bunch of information, but it's also, it says important. This is a historical document, even though it's just finally here, but it's been working, being worked on for five years. The, the actual information then is in, in, the Sentinel information now in the documentation.
So we can, we can click over and look at, I already had it up, look at Sentinel Values and they're kind of neat. So I, I'm excited about this. I don't, I don't quite understand some of the information, the decisions, but that's okay. So, we often use like none for Sentinel value or some, or Nan, if you're doing, like floating point stuff.
But the object, one of the interesting things is it acts kind of like none you use is like if, if you want to check a variable or, an element, if it is the Sentinel, you can say is, is missing. and, and then in the types, the type is handled interestingly. The, the object is both the value and the type.
So you can say like a default, like some variable is, is of a, of type int or the pipe operator or missing. So you can, you can have that together and it isn't missing altogether. Missing isn't the magical, magical Sentinel value. You can have anything like, not available or whatever you want to call it.
so if you're going through a list, like an array, and, and you want to check to see if it's Sentinel, you have to say is your Sentinel, you know, if you use the is operator to make sure it's there, you can't like none, you could just say if like, you know, if the value in, if that's true, that means it's not none because none is evaluates to false.
All the Sentinels evaluate to true. so you have to treat it differently. All right. I'm already feeling a PEP to enhance the Sentinel coming on. to, to make it, to flip the values. but what do you mean? You know what? I love the idea of a Sentinel. I love it because it lets you check, you know, it's like if you're doing a, you know, find me the index of this thing, this item in a string and it's negative one, which is also an integer, but like, that's the, that's means it's not there.
Right. Yeah. And that's cool. Why not give it a default? I'm even in true, I guess, for compatibility at this point you would have to do, but why not give it a second variable? You could pass like a falseness, like, is it true or false? Like comma false. And then boom. Okay. If this Sentinel comes up and I say, if value, no, this is not a value because it indicates the absence of a value.
It doesn't break anything, but allow you to pass false. So if you, if it or anything like where it's truthness, truthiness has to be checked. Then it can be what it says it is because you might have a Sentinel for two different outcomes, right? That's plausible, I guess. Although it's not usually the way it's used.
Yeah. But like a lot of, I mean, for Sentinels for, to mean I've like, I've got a big vector of stuff. I want to know if there's, if it's not filled out. yeah, I think the default should be false. Primarily Sentinels are used in the case where something didn't work out right. Normally you get a value, but sometimes you get a special value.
But, I don't know. I do like that. You don't have to do that with none. You can just say that it's just values false. I do like the, I like the idea. I think that maybe you should get on that whole PEP thing for, for extending that Michael won't you? Yeah. Before you scroll that screen, let me work on my second version of the PEP.
Empty strings are objects and they evaluate the false. Yeah, yeah, yeah, exactly. Like you can, there's a magic method to say false. They just return the value of the parameter that goes in when you created it, right? I think it's, it's like a five minute implementation and 47 hour, like documentation and negotiation afterwards.
But here's the other one. I think this is more subtle. There's an example saying like, how do I express in the type system that something might be of the value expect or the value that is the Sentinel. And this was much, I think this is a much more significant, probably not going to use this after all sort of thing in my mind.
Let me set the stage. If I have a function that returns none or integer, and I say X plus Y where X came from that function, my type checker will say, oh, you cannot plus that with another integer because none does not allow addition with integer. So you can say, if is not none, X plus Y will work without the type checker failing.
But if you just say X plus Y types fall apart, it gets all upset. I'm pretty sure that's what's going to happen here with Sentinels. Your type has to be, I return an int or missing or an int or the Sentinel. The Sentinel does not have type information based on an integer. And so any int operation on it will fail.
And the type checker is going to warn. So you're going to have to add all of these, like, I know it said it was an int or a Sentinel, but it's not any longer. Now it's just an int. And I feel like there's a lot of clumsiness that's going to go, go along with like trying to work with things that express themselves as int or Sentinel.
So can we just add another, another type, another parameter to the creation? Like it's a Sentinel of int. It's a Sentinel of... Yeah, but we're not going to get it for 3.15, but maybe we can get it later. No, no. I'm just saying like, wouldn't it be nice if you could have it also be the type so you don't have to express in the type system that it is something else?
I think they provide a really interesting goal. Yeah. Yep. do you have any extras? Of course. Yeah. You know what? I got some stuff to talk about. Let me swap it over. I didn't have any extras written down, but then I decided I have extras. So I haven't talked about this yet, but, if I go over at Talk Python training, I've done some cool stuff.
And now if I click on the CC, I get English, German, and this one even has Spanish. How about that? Nice. Yeah. So I could turn on like German transcripts and, you know, they're on the screen. Maybe those are too big. So I can make them a little smaller, put them up at the top. So they're not in the way.
So I've done a ton of work on the transcripts over here. And now guess what Vincent's speaking German now, right? Let's go. So anyway, if, if you were a German speaker, check out the courses, and turn on the subtitles for German, if you like. I'm wondering how, like when we're going to have AI tools that can not just do different translations for subtitles, but can we get like dubbing in the original speaker's voice?
That'd be cool. Hold that thought. All right. That's my extra. We have a German subtitles for all the courses that talk Python, all 280 hours. And I would just like to point, I said this in the blog post, but just to listen to 280 hours of audio is seven weeks, almost two months of work, not the translating, not the double checking just to listen to is seven weeks worth of work, 40 hours, you know, eight hours a day, five days a week sort of thing.
So before, before GitHub, basically the, like it's talking about this, like we're at, we're at an inflection point, not sure where we're going to go forward. But before GitHub, it was a weird place. We had basically, source controls roll your own or do something wacky or, it was, it was a very different experience.
So we're, and I have to agree. I am even at the state of GitHub right now, I'm still using it a lot and other things, but I also understand some of the gripes people have, there's political stuff and with AI and everything. But aside from that and whether or not they should have been able to just steal everybody's content, or intellectual property, because open source does not mean please just, you know, train your AIs on it.
But anyway, regardless of that, the, there's a, there's another, there's another aspect of it that the GitHub is really built around community building and collab getting as many collaborators as possible. And it doesn't often work that way. I mean, we often get a lot of people submitting issues and griping about things, but not a lot of people contributing actual good code contribute contributions.
But now there's some bigger ones. And, and one of the things that I'm grateful for is he brought up tenacity and I'm like, what's tenacity? I don't know what that is. And it's a, it's a total tangent for the topic, but it's a, cross platform, multi-track audio editor and recorder that I'd never heard of.
And it looks pretty cool. So I might check that out. It's an open source thing. Anyway. Oh, that's very cool. I've used audacity and I bet it is a, a riff on audacity, right? But yeah, yeah, yeah. Now I'm definitely checking this out. This is cool. Yeah. So I definitely want to check that out, even though I, I, I'm happy with my audio situation right now.
But anyway, the interesting thing around this that I, I, it's a, it's an interesting topic and it's not a really long article. One of the things he talks about really is when, if we go to Codeberg or other roll your own stuff and have source code, like all over the place, we do lose some things because even, even though you can clone, you can do things that conversations are less, we have less conversations around, around issues around the direction of some projects.
And if it goes away, if somebody deletes their repo, we lose all of that. so there's some archive possibly needed some history that would be helpful. anyway, interesting discussion around, around that here. So thanks, Armin. Yeah. Very nice article, Armin. And I've really appreciated his, his thought pieces and his writing over the last year or two.
So good job. Yeah. Yeah. Also Hugo out in the audience said, Hey, don't forget Python 314.5 is now out with the new, which is actually the old GC and 315 beta one, the feature freezes out. So yes. Thank you so much for that. Like most notably the garbage collector GC has changed back to the full pausing one, not the incremental one.
Everything old is new again. Yeah, exactly. Here we go. Back around. All right. tell us a joke. Ready for a joke. So, I've been thinking about like everybody's saying, Oh, like now that with AI and everything, I can write my own software. I don't need software engineers. So it reminded me of this XKCD.
So I'm bringing this up. So it's a make it yourself, make it, make it, make it myself, XKCD. And there's two people looking at a couple boxes and I'll just read it out to you. It's mostly text. They want $80 for this. I could make one myself for $10 in parts, an hour of work, a trip to the hardware store, another $30 for parts, another few hours of work, two more trips to the store for $20 more in parts, another hour to redo the first hour of work because I messed it up and $80 to buy this when the one I made breaks.
So that is so true. It's a hundred percent true. Yeah. Yeah, exactly. And I don't, that's why I think this whole vibe coding thing, you know, there was the SaaS apocalypse. And I think that's going to be a very focused and very narrow impact because it's like, yeah, you can make it and you got to back it up and maintain it and run it and operationally and secure it.
And you know what? Let's just let them run it for 10 bucks. Yeah. I think I'm, I'm hoping that it will drive. I mean, not the, I think it'll change the dynamics of how people make money about software, but I do think that I'm hoping we get more good SaaS out there and some of the, the, even if it's helped being made by AI, but the good ones will stick around even if they get, have to get really recoded.
