Python 3.11 is here! Keeping with the annual release cycle, the Python Core devs have released
the latest version of Python, and this one is a big one. It has more friendly error messages
and is massively faster than 3.10, being between 10 to 60% faster in general, which is a big deal
for a year-over-year release of a 30-year-old platform. On this episode, we have Erit Katril,
Pablo Galindo-Sogato, Mark Shannon, and Brant Booker, all of whom participated in releasing
Python this week, the hero on Talk Python, to tell us all about that process and some of the
highlight features. This is Talk Python to Me, episode 388, recorded October 28, 2022.
Welcome to Talk Python to Me, a weekly podcast on Python. This is your host, Michael Kennedy.
Follow me on Twitter, where I'm @mkennedy, and keep up with the show and listen to past
episodes at talkpython.fm. And follow the show on Twitter via at Talk Python. We've started streaming
most of our episodes live on YouTube. Subscribe to our YouTube channel over at talkpython.fm
slash YouTube to get notified about upcoming shows and be part of that episode. This episode is sponsored
by Sentry. Don't let those errors go unnoticed. Use Sentry. Get started at talkpython.fm slash
Sentry. And it's brought to you by Command Line Heroes, an original podcast from Red Hat that
chronicles the history of the software industry. Listen to an episode at talkpython.fm slash
heroes. Transcripts for this episode are sponsored by Assembly AI, the API platform for state-of-the-art
AI models that automatically transcribe and understand audio data at a large scale. To learn more,
visit talkpython.fm/assemblyai. Hey, everyone. Welcome to Talk Python to Me. It's
great to have you all here. Erit, Brant, Pablo, and Mark. It's going to be super fun to speak with
all of you about Python 3.11. Before we get into it, I guess, just real quickly, I know some of you
have been on the show before, but not all of you. So let's just do a quick introduction about who you
are and how you ended up here on the show. Erit, you want to start first?
Yeah. Hi, I'm Erit, I'm a Python Core Dev. Earlier in the week, we streamed the release
of Python 3.11. And on the back of that, Michael just invited us all here for chat.
Fantastic. Yeah. That was a great live stream. And we'll talk about that for sure in a second.
But Brant, welcome back.
Hello. My name is Brant Bucher. I have been a Core Dev for like two years now. And I work with
Mark and Erit on the Faster CPython team at Microsoft.
Right on.
And I was on the show like a month ago.
Yeah, you were talking about the Faster Python stuff, which we'll touch on again.
Hello. I'm Pablo Galindo. I'm the infamous release manager. I released Python 3.11. And you can
redirect all your complaints to my email address. No, please don't do that. So I'm a cPython
core dev. I'm also serving this year and the last year on the Python steering council. And I
also released a release manager for Python 3.10 and 3.11, which is now the best version of Python.
Download it today. Apart from that, I do a bunch of parser stuff. But now we are not talking about
Yeah, fantastic. Well, welcome. Mark, welcome back.
Hi there. I'm Mark Chan. I'm the tech lead of the Faster CPython team. I work with Erit and Brant. I've been a Core Dev for some number of years. I don't
recall. You've been spending a couple years working on this Faster CPython thing and very excited to see some of the fruits of those labors, you know, starting to show up and get in the hands of everyone with this release.
Yeah, it's good to have the stuff out actually in public and in people's hands. It's really rewarding to know that stuff you're working on is actually used and used by a lot of people.
Yeah, that is totally true. It's it's one thing to build software. I mean, just by itself, but it's fun. But all of you are working on code that touches so many people. Think about there's layers, right? One layer is how many people use Python? Many millions, millions. Does anyone know a reasonable estimate of this number?
I think some I don't remember who came with the number, but I think they were estimating like 6 million Python developers, something like that. I mean, probably is between zero and 10 million, let's say.
Yeah, that's a massive impact. But and also maybe nervousness about pushing code out to that group. But then, you know, those people will build software for others, right? If you're using Instagram or using YouTube or other things, right? It's also having massive knock on effects there.
So thanks for putting all this together. Thanks for improving the tools that we all get to use. So yeah, big news. The big news is that Python 3.11 is out.
And as Eric had said, you all live streamed that release. So here we're all together. We're having an awesome chat about the features and the what people can do to take advantage of it and why they might care about new features and want to learn them.
But there you did a little bit of that. But also Pablo, you actually step by step did the release of CPython mostly live, right?
Yeah, I did. It was except the boring part. This is something that I started last year because apparently I didn't have enough things to worry. And I decided to make my life even more difficult. I'm an expert on that. Quite proficient.
I'm also an expert. I'm very bad at doing too many things.
And you could be a release manager is the only requirement. So yeah, the idea is that the kind of releasing Python is a process that is quite complicated. It's also quite boring. So it's not like, you know, you need to be have a galaxy brain kind of thing to do it. But it's just a lot of steps and it's very easy to do it wrong.
And it's very glamorous. So I said, Oh, wow, I'm sure people really would like to see a very glamorous process happen in life. And then I said, Let's do it.
And I asked around and I was surprised about how many people enjoy and glamorous processes. And then I did the release of Python 310 beta one, which turned out to be much funnier than I thought because we just broke GitHub. That happened live. Yes.
Was that when you imported all the, you imported all the issues and did that migration or was that separate?
You will think that that is a good candidate, but no, that was not the thing that broke GitHub. We renamed master to main on the CPython repo and the whole GitHub platform was down. What about that?
Wow.
Yeah, you can see those Ruby workers really struggling with the renaming, all those forks. I think we were the, I don't know, someone at GitHub may confirm this, but I think we were the first big project to do the renaming. Something went wrong.
And it was very funny because I literally said, How funny will it be if now I get a 500? There you go. A 500 on the screen. Yeah. Yeah. It's recorded. There is someone actually recorded that clip. Yeah. Yeah. So I said, Wow, man, this has been a such exciting thing that I can break such a big project. Let's do it more.
So I decided also to stream the 3.10 release itself. And I said, Well, technically the release, the final release is even more boring and longer. So that is actually probably not going to be even like, you know, something that someone went to see. So I said, Okay, let's not do it alone.
So I invited a bunch of friends and core developers. So they can actually talk about, you know, the things that they worked on the Python 3.10 release and brand unneeded were there. So that they can, they can probably tell you how they found out. But like, apparently, it was something that a lot of people enjoy. Because, you know, it's not only an opportunity to see how the sausage is made. Because, you know, I was just explaining all the commands and all the faces and whatnot. But like, when something became very boring, then, you know, like brand unneeded were there to save the day.
And explain the cool things they work on. So, you know, which is a very good opportunity. Because, you know, when is the last time you could hear the author of the feature that you love talk about the feature that you love? That is fantastic. And it happened.
Right. And not only did it happen, but as they were explaining the feature that they built, the action of it being delivered to the entire world was right. It was like all coming together in a pretty awesome way.
Exactly. And I could only do that just to be fair also. And, you know, credit where credit is due.
I could only do that because the first time I did the live thing, I was also doing all the, you know, pushing all the buttons and at the same time doing all the video stuff with, I don't know what is the software to the stream or like whatever.
And the second time we used the help of the Python Discord team, which are fantastic. And they help us a lot. They have this fantastic UI where, you know, all the questions that were asked on the chat are on the screen and we couldn't use it.
Do you know why? Because Facebook or now Meta decided to break DNS globally. What an incredible feat.
Just in time.
I think wanna.
So what I'm learning is if we need some sort of like big cloud global outage, you all just need to live stream.
Just call Pablo.
Yes. Exactly. Exactly.
Exactly. Just hire me today.
Okay.
So yes, now we were like two big outages on Python release. The, you know, there is only a line that passes through two points, but I, you know, it was a, it was a, it's a good, a good statistic already.
So we said, what can I, what else can we break? So there you go. We decided to do the 3.11 release again. And Mark was there as well, which increases the probability of things being broken by a lot.
Sorry, Mark. I had to do the joke. He also fixes them. So, you know, it's fine. And nothing broke. So, so kudos to Mark. Everything. Thanks to that.
And we did the release. So, so we did the same thing. We explained the whole thing. So people could see from the authors themselves, like why all the switches are very cool. And I did the non boring parts of the release.
And then we have a bit of some dramas in backstage because my Jubi key that I used to sign release broke and I freak out quite a lot, but I thankfully have a backup Jubi key. So no, I have, yeah. Yeah. So crazy.
Because if I didn't have that, then I will have to stop the whole thing, but we didn't have to do that. It was just backstage. So yeah, quite, quite exciting. Nothing broke except my Jubi key. I suppose that's the third thing that broke. It's not a global, you know, software, but I still mourn it. It's here.
Yeah. It served you well, but now it's, it gave its life for Python 3.11.
Too much power. Like 3.11 was too powerful. It just broke.
This is a dangerous job that you got.
Yeah.
But you've handed it off, right? This is your last time, last main release.
Yeah. Yeah. I need to do the security and bug fix releases, but I don't need to do the ones that, you know, you need to chase people down and ask for like cherry picking. And there was a bunch of things of the release that were quite boring. Like normally we release the previous version. Like before the final version, there is something called the release candidate, which is, you know, like the last version that people need to try out before we do the final release.
And ideally that is the last version that we publish. Normally it means that you publish from that commit.
But, but this was not the case. This is the first release that had 130 something commits on top of that.
But I have to painstakingly cherry pick and it was not fun, but I did that before the release. It's like two hours.
Yeah.
You need to fix conflicts and things like that. Yeah. Very, very boring. But yeah, I started the stream with that already done. So, so it was fine.
Yeah. Fantastic. Now, before we get into all the features and I want to maybe just talk a little bit about some of the tools for actually doing the release and maybe start with you is, what, what is 3.11 mean for you all getting this out? What does that mean for the Python community from your perspective?
Well, 3.11 is, it is a huge release. There's a lot packed into it compared to the last few releases. There are no features. There's the performance work. It's, it's just massive changes internally. It's, it's just a huge release. And personally, I've started working on, you know, exception groups about two years ago.
So for me, this is, it almost feels like finishing another PhD or something. It's, it's a massive kind of effort and here it is. It's done. It's, you know, it was a big day Monday. I had a bottle of champagne ready for the stream. It was a celebration.
Yeah, it was. Brent, how about you?
I'm really excited about 3.11 because I think there's something for everyone. And I think you'd be hard pressed to find someone who doesn't want their code to run faster and who doesn't want better error messages. And then you have all these other improvements on top of that.
It's really nice to see both these like new features, which are something that we get in most Python releases, but also just the stuff that's there for everyone else who just wants to upgrade Python and just have a better experience all around.
Yeah, I totally agree with that.
It's cool to see people's responses to that too, because responses have been really, really positive, which is another thing that I liked about the live stream because we did, you know, live Q&A and we had the chat and everything going on. And when you're starting at the same code base for like a year, you're like, okay, I'm pretty sure that what we've done here is really, really cool.
Cool. But, you know, like, is it actually as awesome as I think it is? You know, or have I just been staring at it for too long and then release it to the world and people are even more stoked about it than you are. And that's a really good feeling.
Yeah, it is. Awesome. Mark?
Yeah, well, I guess I started on trying to get Python faster 15 years ago, I guess, early PhD time.
Yeah, with Hot Pie, right?
Yeah, yeah. So that was a long, long. This has been a long time coming. So yeah, it's amazing to have it actually out and starting to see the speed ups. And obviously we're keeping working on it. So it's pretty good.
Yeah, fantastic. You must be really proud because, like you said, you have been proposing this for a really long time. You've had a lot of ideas. And finally, you've got a group of people working on it. And you're all on the same team with Mark and Guido.
Yes.
Yeah. And just making legitimate, serious progress here. So it's, you must be really proud to just sort of see this actually go out the door.
Yes, definitely.
Especially in main iPhone too. It's really nice that we're able to, you know, deliver this for everyone.
Yeah. For me, I see basically three things, like, kind of like you said, Brent, I see that obviously there's these new features like exception groups, which are lovely and make the language better.
But it also gets friendlier for, especially for beginners, but for everyone, of course, with the better error messages and better reporting and tracebacks. And it gets faster. And so, I mean, it, and all the axes that seem to matter. It's, it's really fantastic.
Okay. So let's dive in. I just, Pablo, let's go back just a little bit to the, the release process because people got to watch you do it, but they didn't actually, you know, see exactly what you're typing on your screen the whole time. It was more of about a, like an event of it. Sometimes your screen was up, sometimes it wasn't, but there's an official PEP that talks about like, here's the recipe for doing this, right?
But it's correct. It's PEP 101 doing Python releases. And that is a curious document. It's peculiar document. Talks about how it's done, but it's like, it's kind of weird. So the document is up to date. Like you can actually, you know, search PEP 101 and it will show you the thing.
So what is there is the actual process. It's just, it also contains these weird sentences. Like if you search for it, there is a bunch of places that says stop, stop, stop, stop, stop. Quite funny. And that was, if I recall correctly, Larry Hastings.
That he wrote those things and the idea is that he could search for those places. And he knows that at that stage, he needs to wait for something to happen or something. And we left it there. So there's a bunch of like weird artifacts and, you know, it's full of bullet points because you, at some stages, you need to do some things and some others and things like that.
And, you know, it says, okay, if you're running a beta release, then you need to do this bunch of things. And if you're running an alpha release, you need to do this bunch of things. And I have done the, I have done a state machine that goes through the whole thing because like, if you actually write this down, it's quiet, is, you know, the, the, how is this called? The maintainability index of this process is insane. It just rejects your thing.
Right. And I said like, yeah, I'm not doing this reading. So one thing I did, which is the thing that I was using at the, at the stream, my first work as a release manager is say, I'm not going to do this by hand. And that is the vision. And then I did this script that is on a GitHub slash Python slash release tools. And it's a, it's my attempt at automating this process as much as possible, which unfortunately, you know, it still requires a bunch of manual steps because like that's a lot of work.
that's life and things happen. But, it's quite automatic, like at least things that are not like final releases. So alpha and release candidates. And now that we are in backfix releases, it mostly runs automatically, except that, you know, in the final release, everything fails because there's the final release for you. And then you need to fix things manually. So you, I think you saw me, you know, executing a bunch of those fixes at some point. And I added a division by zero just to know that something was hit and that was seen on the screen because like, and people
like division by zero, why do you need that to release Python? I don't know. That's very complicated.
I could have asserted false. Come on. Anything would have worked.
No, no. We divide by zero. I'm a physicist. So that's what I do.
Okay.
You studied black holes, right?
Yeah.
You were looking for some sort of like infinite sort of thing there. Divide by zero. Yeah.
I'm too tired for today. Let's just collapse the universe. Divide by zero. Oh, but Python was too friendly. Instead of collapsing the universe, it sold me an exception. You know, quite nice. Only in 311. No, no, I'm joking.
This portion of Talk Python To Me is brought to you by Sentry. How would you like to remove a little stress from your life? Do you worry that users may be encountering errors, slowdowns, or crashes with your app right now? Would you even know it until they sent you that support email? How much better would it be to have the error or performance details immediately sent to you, including the call stack and values of local variables and the active user recorded in the report? With Sentry, this is not only possible, it's simple.
In fact, we use Sentry on all the Talk Python web properties. We've actually fixed a bug triggered by a user and had the upgrade ready to roll out as we got the support email. That was a great email to write back. Hey, we already saw your error and have already rolled out the fix. Imagine their surprise. Surprise and delight your users.
Create your Sentry account at talkpython.fm/sentry. And if you sign up with the code Talk Python, all one word, it's good for two free months of Sentry's business plan, which will give you up to 20 times as many monthly events as well as other features. Create better software, delight your users, and support the podcast. Visit talkpython.fm/sentry and use the coupon code Talk Python.
Anyway, so yes, yes, you can follow this PEP and, you know, just enjoy the whole process on its glory or you can see the script. But yeah, it's quite verbose. You can see that it's very, it's lots of places when everything can go wrong and you can panic.
Now we know one more.
Apparently your jubi key can break.
So that's something that can happen as well.
But like, you know, it's quite annoying.
And that's the main job of the release manager.
I go through this annoying process.
So yeah, I see that there's some parts in here.
You should have a few more stops.
I should say stop, stop, stop.
Make sure GitHub still works.
Stop, stop, stop.
Make sure Azure still works.
Stop, stop, stop.
Yeah, don't cry.
Don't cry at this stage.
Everyone is looking at you.
But yeah, the one thing that is knowing this is that you also are in charge
in theory of this extreme abstract mandate, which is that you're in charge
of the stability of the release, whatever that means.
That translates mostly on chasing people because they broke things.
Another unfortunate event that we are trying to also fix a bit for the for the releases
is that most people turn to the release manager to solve problems.
So they say, hey, this person says that we should do X while this other person says
that we should do Y.
We need someone to decide.
Let's let's let's let's reach the release manager.
But the release manager is this guy on the corner.
Like he doesn't know shit.
So I like, you know, it's not the best person to fetch it.
But everybody was like, what do you think, Pablo?
So we merge this.
I like, I don't know, man.
This is some in-and thanks.
Like, I don't know about this.
I have no context whatsoever.
Your only concern is will it still build and shift?
Exactly.
Like how?
I like it.
Yeah.
What about these 2000 lines?
Of course, it's all this tiny bag.
It was like, well, maybe let's not merge to that.
But yeah, like we are trying to also like, you know, redirect all of these to the steering
council, which also I am in the steering council.
So apparently I'm not going to get rid of these questions.
I'm joking.
I enjoy all these questions.
But as a release manager, I don't.
So I like the key here is that the release manager should not take unilateral decisions
on the evolution of these things because like it's just the release manager.
the reason the steering council is five people.
But you are the one who delivers the code.
You could kind of, you could sneak a feature in there.
No, no, no.
Come on.
I don't decide important things.
I just execute and chase people.
And I'm this annoying guy that says, you broke this, fix it.
But like then if there is some important decisions to be taken, you know, that's the steering
council job, which is five people because, you know, one person shouldn't decide these
things.
It's like, and this happens.
Like sometimes I say, hey, there is this PR when people are asking, what should we do?
And then this is my opinion as the member of the steering council and the other four
members, maybe they say, well, actually that's not a good opinion.
So what about this?
You know, we ended up in a much better place because it was five people, five persons doing
a decision instead of one.
But yeah.
Yeah.
Amazing.
Okay.
So if people want to follow along with the process, they can check out PEP 101.
Let's keep over here.
You also talked about the Python build bot that people can check out, but I think maybe we
want to jump into our first feature.
There's, as Arit said, there's a ton of features and things in here, but there's also maybe
some top level ones that'll be really important for a lot of folks.
And Arit, you want to tell us about your work?
You mentioned before the exception groups and exception star.
This is kind of a major new feature that we added.
And the idea is that sometimes you'll have a situation where you did several things and
maybe more than one of them raised an exception.
And now you need to report that there was more than one error in whatever you did.
And what you did could have been a bunch of asynchronous tasks, which is that that was
the use case that motivated this whole thing.
But there are also kind of situations where you just iterate over a few things and repeat
them and accumulate exceptions.
And you want to kind of report all of them.
And the PEP lists a bunch of examples of where this can happen.
So people typically what they do is they'll take a list of exceptions, wrap it in another
exception, multi-error, some other kind of wrapper and throw that.
And then you have to catch it.
And then you have to iterate over the list and look at the exceptions.
But you don't have a method to handle the exceptions.
Like you have try accept, like catch these, but not catch exceptions.
Right.
Because in accept, you might have like accept socket error, or you might have accept like
file not found type of thing.
But if those both happen, neither of those would run in Python 3.10, right?
Because it's some kind of weird wrapper and it's not a socket exception.
It's not a file exception, but it kind of contains both.
And so in a sense, you would both run?
I don't know.
And then if you catch the wrapper, even you do something with some of the exceptions,
you better not forget to erase the rest because you're not handling them.
So yeah, there are a lot of problems when you try to work around this and like what happened
with Trio.
So Trio had multi-error, would raise this wrapper and it had to do a lot of complicated
acrobatics just to have some error handling.
So the motivation was, yeah, we have task groups in Python 3.11, which are kind of like Trio
nurseries, kind of a structured collection of asynchronous tasks.
And task groups were on the cards.
They started like Yuri Selibanov, who was kind of maintaining asyncio in the beginning.
He wrote a lot of asyncio.
He wanted to add task groups since 2017, 2018, something like that.
And what was holding it up was error handling.
There was no good way to handle errors.
So now we have accept star, which is what generalizes accept and works with groups.
So you can say accept star socket error.
And then it will just extract all the socket errors from the group and give you those and
automatically re-erase everything else.
That's basically the idea.
This is pretty interesting.
We have try, do your thing, and then accept star, you know, one error type, accept star,
another error type, accept star, a set of errors potentially.
So what happens if I'm in this situation and say the first error type and maybe something
from the third error catch clause is thrown in one of these task groups, exception groups?
Each exception in the group will be handled by at most one of the clauses.
So the first clause that matches its type will consume it.
And each clause executes once.
So if there are more than one errors of that type, then what gets kind of bound in the accept
star full error as E, what gets bound to E is a group of full errors.
So you get all the full errors in a group, execute that clause, and then move on to the next clause
with whatever is not handled yet.
Interesting.
So it might run two of the clauses.
Exactly.
Whereas in traditional exception handling, it goes from top to bottom and it looks for an
inheritance type of match.
And the first one that matches, that's it.
But in this case with the star, you could get multiple ones.
I guess the star to me, when I look at this, the star is reminiscent of Args star where you
have...
Unpacking.
Yeah.
Yeah, exactly.
It's not exactly unpacking, but it was kind of the intention to make it look a bit like
unpacking.
Nice.
Yeah.
This looks like a really cool feature.
You talked about the task groups and trio and those things.
So when I saw this, concurrent errors obviously come to mind because if I try to both write
something to a database and call a web service asynchronously and I start both of those and
they both crash or multiple ones crash, which error do you want?
The database error or do you want the API error?
You probably want to know about both of them, right?
So that's a real natural reason to bring these together.
But maybe you'll also list out some of the other reasons that you might run into this.
Maybe give people some other ideas.
So the example of in the socket module, we have the create connection function.
And that function, I was showing it in the stream.
It iterates over all the configurations that you could try to connect with.
And then depending on what's going on on the other side, hopefully one of them works.
But if none of them work, you have to report errors.
And what we do in Python 3.10 is we just raise the last exception.
So you don't know what happened really.
You only know why the last attempt failed.
You don't even know how many attempts were made to connect to.
How many configurations did we try?
So that was a long-standing open problem.
Can we do better than just report the last error?
And we closed it.
We just added it for us to that.
Give me a demo for in a group.
Another place that comes to mind is maybe you're all familiar with some of these retry libraries.
Yeah.
Like, I think there's others as well.
Where you put a decorator onto some function.
You say, try this multiple times.
And if it fails, do some sort of exponential backoff because maybe the server is overloaded.
Right?
Those types of things would be really great.
Like, if it retries all the times it's supposed to and it fails, it'd be good to get all the errors.
Not just the last one or the first one or whatever it decided it was going to give you.
Yeah.
It's the kind of thing.
Yeah.
Nice.
Okay.
Well, congratulations on getting that feature out.
That's great.
All right.
What do we got next here?
I think also related to this, I wanted to talk about this PEP678.
That's a very small and simple feature that Zach Hadford Dodds wrote this PEP.
He was trying out Exception Groups.
He was the first kind of user.
Even before the PR was merged, he was trying it out.
He was trying to integrate it with the hypothesis library.
So there you write a test and the library executes it many times with different inputs and you
get failures in some of the inputs and you want to report all of them.
So Zach had an Exception Group, kind of an Exception Rapper, kind of like Trio Multi-Error.
He had his own version that he built in his library and he could associate each exception he attached
to it, which input generated this error, which is very important.
You need to tell people what the input was and what happened with it.
And he couldn't do that in a convenient way with Exception Groups.
He added this to base exception.
You can add strings.
You call it add note, give it a string and you can call it as many times as you want and add notes to the exceptions and they will appear in the default traceback that the interpreter prints.
So that's all it is.
It's a very simple feature, but it was received surprisingly well.
It's a very simple feature that you can enrich an exception after you catch it.
So you have the information that, you know, the error message and the type, you decide that when you raise the exception.
But then sometimes when you're catching, there's some more information, some context, like what was I trying to do when this error happened?
Sure. Yeah.
Because often you'll see, except some type, some exception type, you'll deal with what you can, but you can't really handle it there.
So you got to raise it again.
And this is a place to add more information without completely wrapping it.
Right.
Exactly.
A lot of people have to chain it.
Say this raised from that.
So there will be situations where maybe you won't need to do that.
Yeah.
I'd love to see that go away.
I sort of template libraries and stuff in the web all the time.
I see like there's all these different errors and you got to hunt through a bunch of stuff to figure out what happened.
Yeah.
Also think about, for instance, like I think this is super useful actually for end users.
Even like we think about that you're doing some query to the database.
Right.
And then, I don't know, it may fail for 6 million reasons.
And then you want to add what you're asking for.
Right.
So you add your query or your user or whatever.
Because probably the exception that the Postgres thingy that is underneath is not going to contain your actual thing.
So this actually may save you hours.
Right.
Because in many enterprise environments, you don't even have easy access to that.
Sorry, to prod.
So you cannot just go there and see what's going on.
So it would be super cool that you say, oh, if something fails, you know, I was trying to do this with this data and like with these things.
So like if it fails now, you can know what's going on and you don't even need to log in, which is, I think it's a.
Yeah.
It's a great idea.
Or if you know, look, here's probably why this happened as a library developer.
You're like, look, this is the error.
But here's a note.
This is probably because you didn't initialize the connection before you called this.
So make sure, you know, like another area where I see this could be useful is I want to raise like the example you have in the docs is type error.
But it could also, you know, it could be value error or some other built in low level type.
You know, like really, this is just I want to raise that error, but it doesn't have a place for me to put additional information.
And so I want to kind of enrich that with more.
And so not just catch, add the data and then raise it again.
But actually, I want to use a base error type that doesn't let me put more details in it and then just raise that.
Right.
That would also work.
I think so.
I mean, I think the intention was there was some discussions about using notes in the interpreter and I pushed back on it because I said this is owned by the application.
The interpreter shouldn't touch the notes, you know, because people can wipe out the notes.
They can change the order.
They can do what they want.
It's the applications, at least the way I see it.
The application owns it.
You put whatever context you want to put.
Is there only one note?
When I say add note, does that set the note or can I have a list of notes?
It's a list of notes.
Okay, got it.
Yeah.
And you can wipe it out if you want.
You can.
It's just a list.
It's attached to the exception.
You can do what you want with it, really.
Yeah.
Cool.
Okay.
Yeah.
It's a great.
It's a really great feature.
I mean, it's I'm sure it was way less work than except star, but it's also going to be really valuable.
I think.
This portion of Talk Python to Me is brought to you by Command Line Heroes, an original podcast from Red Hat.
Command Line Heroes chronicles the history of the software industry.
If you want to get the big picture on how macOS and Windows became dominant players, as well as how Linux brought its radical open source opinion to the scene, then Season 1 is a fascinating lesson.
In particular, check out OS Wars Part 1 and OS Wars Part 2, The Rise of Linux.
Season 3 is all about programming languages, and it kicks off with a topic near and dear to all the Talk Python listeners, Python's tale.
I even got to be a guest on that episode, as well as Emily Morehouse, who makes a connection between Python's technical extensibility and its inclusive community.
I talk about how Python is both easy to learn and powerful enough to build apps like YouTube and Instagram.
And Diane Mueller highlights how the Python community took the lead on so many inclusive practices that are spreading in tech, including the rise of community-led decision-making.
This award-winning podcast is hosted by Saran Yiparak.
Saran is a fantastic host, and the show is highly polished.
Seriously, if you love the history of software development, jump over to talkpython.fm/heroes and check it out for yourself.
Thank you to Command Line Heroes for keeping this show going strong.
So, Mark, I had you and Guido on back, wow, almost to the day a year ago.
We're off by November 1st, 2021, so not that long ago.
Let's talk a little bit about the work that you're doing there.
I guess the headline is that Python 3.11 is 10 to 60, 10 to 50% faster than previous, sort of on a reasonable range of applications.
Is that the story?
Yeah, somewhere between minus a few percent and plus 100, but it varies a huge amount.
I mean, if you've got some application that basically spends all its time in NumPy or something like that, you're not really going to speed up at all.
But if it's pure Python, you'd expect it to be a good 40, 50% faster.
But it depends.
Right, that's a good point because a lot of people do make Python faster by writing C or Rust or other languages.
And at that point, it's out of your hands, right?
Yeah.
So, I mean, we're looking, hopefully, for 3.12 to start looking at the sort of interface between Python and C code.
So, we should speed up code even though there's quite a lot of C code.
We won't spend up the time spent in the C code in doing the actual work in the C code, but there's still quite a lot of sort of marshalling of data that happens.
And hopefully, we'll streamline that.
The existence of C extensions is sort of, in some ways, limits our opportunity to speed things up, but it's also why Python is so proper in the first place are one of the main reasons.
So, definitely need to acknowledge it.
Yeah, absolutely.
So, Brandt, I'll definitely have you talk about the specializing interpreters, but Mark, maybe give us a rundown of some of the things from your plan that made it in here.
I know some were aimed for 3.10, but they didn't make it until here, right?
Yeah, so the whole thing, oh, that original plan I put up, that was more of a just to get the discussion going sort of thing.
And it's basically, it's more or less a year off.
So, if you just shift everything one forward.
I mean, there was a lot of discussion on speeding up the interpreter in the first iteration and then looking more to the data structures in the second thing.
It's much more jumbled than that.
We're doing sort of a bit of everything.
So, obviously, I was planning on, you know, expecting a smaller team.
So, things are being a bit shuffled.
So, yeah, there's a specializing interpreter, obviously, that's kind of key.
There's also quite a lot of stuff we've done with data structures.
I mean, we shrunk the Python object.
So, I mean, the Python object, you know, has been shrinking for years.
I mean, I've got some numbers here.
So, like in 2.7 and 3.2, like an object with just four attributes would take 352 bytes on a 64-bit machine.
And for 3.11, we've got it down to 112.
And for 3.12, it would be 96.
Well, before you get too excited, it's only 32 in C++.
So, you know, we've got a bit of a way to go.
Yeah, but, you know, it's going in the right direction for sure.
And, you know, sure, some people out there listening just say like, okay, well, it's half the size roughly and it's going to be less than that.
So, yay, we can use less memory.
But maybe you could talk a little bit about how that affects things like L1, L2, L3 cache hits and other sort of, like, it's more important than just I need less RAM, right?
Yeah, yeah.
So, there's two things that happen.
There's, yeah, things are faster because the hardware is just happier.
If you pack everything together, it's in a high-level cache.
So, you're not getting these sort of long pauses as you hit main memory.
And the other thing is just the data structures are, because there's less of them, there's less indirection.
So, for example, to load an attribute, we've got it down for basically an old, you know, older versions of Python.
It was sort of effectively five memory reads.
And they were dependent memory.
You just have to read one before the next one and so on.
Go to the class, find its, go to the object, find its dictionary.
Then find the pointer that's in the dictionary and then go to that, right?
Like, it's...
Yeah, yeah, very much that.
And it's down to more or less two now.
So, I mean, obviously, there's still interpretive overhead on that.
So, it's not quite that much faster, but it's getting there.
So, yeah, there's a data structure.
And then the frames, the Python frames, every time you call a Python function, we used to just allocate a heap object for the frame and all this stuff would go in there.
And now they're all basically in a big contiguous sort of block of memory.
So, it's just bumping a pointer rather than allocating, which is also faster.
And frames are just more anyway because of the zero cost exceptions, which I think we mentioned on the release thing.
But, yeah, this is...
Well, let's tell people about zero cost exceptions.
Okay.
Well, zero cost...
You shouldn't have to pay for errors if you're not raising errors, right?
Yeah, that's the idea.
And that's why they're called zero cost.
But zero cost is in quotes in this.
And the reason for that is it's just...
That's the name it has got.
They're definitely not zero cost.
The idea is that they're pretty low cost if you don't have an exception.
But they tend to be even more expensive if you do get an exception because you have to do more lookup.
The important thing here is that just there was lots of runtime information we need to maintain and we don't now.
So, that, again, shrinks the frames and just makes calls faster because calls in Python were notoriously slow.
So, that's one thing we've sped up significantly.
Yeah.
So, the idea was in previous releases of Python, if you...
Just to enter a try block, even if it was successful, there was a little bit of overhead to set up the mechanisms of potentially handling the errors and the information you needed, right?
Yeah.
And this wasn't just the overhead.
You defer more of that, right?
Yeah.
I mean, it's actually not so much that overhead as just the space you had to put that data in had to be allocated every time you made a call in case there was an exception.
And then we had to...
It was massively over-allocated to the amount of space anyone ever needed.
So, just that was the big sort of advantage.
Nice.
Yeah.
This is fantastic.
You don't want to discourage people from putting proper error handling in their code.
Yeah.
What do you think...
I see your name on this feature here in GitHub.
What are your thoughts on it?
Yeah, I think it's cool.
And I was kind of...
You know, it was a nice touch that Mark implemented it between when I wrote the prototype for exception groups and when the PEP was approved.
So, that got in the way a little bit.
But it was good.
I got intimately acquainted with zero-cost exceptions through that exercise.
Well, it's zero-cost for some people.
Yeah.
I tease Mark a lot about that.
No, I think it's a cool feature.
And I mean, I followed up on that.
We now have...
After we removed that, we still had a...
I was talking about this on Monday.
We had to jump over the exception handler.
And then I told them, wait a minute, there's a jump.
It's not zero.
You have to jump over the exception handler if there's no exception.
So, now we have...
We did...
We identify exception handlers as cold blocks.
And before we lay out the code of the function, we put all the code blocks in the end.
So, now if there's no exception, there isn't even an exception handler to jump over.
That would be in 312.
Excellent.
You made zero-cost even faster.
So, now it's...
Zero even smaller.
Yeah.
It's asymptotically approaching zero.
Yeah.
So, but it's kind of nice that we have this notion of cold blocks and hot blocks and we
can maybe do other things with it.
Kind of nice that all the happy...
But the fast code is kind of in the beginning of the functions bytecode block.
And, you know, in terms of caches and all that, you don't have to...
I think it will bring a few benefits beyond just not having to jump.
Yeah.
This is excellent.
It's a really great feature and pretty straightforward.
All right.
Brent, tell us about the specializing adaptive interpreter.
That's a big deal.
You and I spoke about that about six weeks ago, I think.
Yeah.
Basically, the headline is the bytecode changes while it's running to adapt to your code,
which is really neat.
So, it's kind of finding places where we can do the same thing, but using less work by like
cheating a little bit.
But cheating in a way that is not visible at all.
A good example is something like a global load or a load from the built-in.
So, if I'm looking at like the len function, that requires two dictionary lookups.
Every time I want to look at the len function anywhere, I first need to check the global namespace
and that's going to be a failed lookup.
Then I need to check the built-ins dictionary and that's going to be a successful lookup.
So, every time I want to use len or range or list or any of those built-ins, that's the
cost that I have to pay.
But people don't change the global namespace that often.
And people change the built-ins namespace even less often, or at least they shouldn't be
changing it very often.
I'm going to make false true and true false.
Let's see what that is.
And so, you can make these observations where it's like, okay, well, if the set of keys in
the global namespace hasn't changed since last time this bytecode instruction ran, then I
know that that lookup is going to fail.
Because if it failed last time and the keys are the same, then it's going to fail this time
as well.
So, we can just skip that.
And same for the built-ins dictionary.
You know, if we know that the keys in that dictionary haven't changed, that actually means that the
internal layout of the dictionary is the same.
And we don't even need to look up len in the built-ins dictionary.
We can reach directly to the last location where it was before and give you that instead.
So, you obviously see in a lot of code as like an older code as a kind of a micro-optimization.
Whenever someone was using a built-in in like a very hot Python loop, sometimes you'd see
them like do this kind of quark trick where they make it a local variable by saying like
len equals len or something like that as part of the functions arguments.
So that you turn it into a fast local load.
And what we've essentially done is, you know, made ugly acts like that totally unnecessary.
Yeah.
Which is really cool.
You do that behind the scenes transparently.
Yeah.
Exactly.
And so that's just, you know, one example.
We've done tons of specializations for all sorts of things ranging from calls to attribute
lookups to attribute stores, et cetera.
So yeah, it's a really, really powerful thing.
What was it?
It's the 569?
Yeah.
Mark wrote it.
It was 659.
659.
Almost there.
Yeah.
So this interpreter is Mark's baby.
He could tell you much more about it than I could.
Yeah.
I just want to give you a chance to give a shout out about specialist.
Yeah.
So this is why I was on your show.
A couple of weeks ago.
So looking at bytecode disassemblies is not fun.
And so one thing that's kind of cool is, you know, if you upgrade to Python 3.11, you run
your code and you saw it got, you know, 10, 20, 30% faster.
You might be wondering like, okay, where did it get faster?
Like what is faster about my code?
And so specialist is basically a package that I made.
It's pip installable.
It only works on 3.11.
And basically if you run your code using specialist instead of Python.
So you just type specialist, my project.
So you just type specialist, my project.by or whatever.
It will open a web browser and show you your code, but color highlighted to show you where
the interpreter was able to specialize your code, where it wasn't.
And that's really neat.
So you can see like, oh, actually, you know, these are the attribute loads that got faster.
These are the places where my global loads are being cached.
That's perfect.
Yeah.
That's awesome.
Yeah.
This is a really cool project.
And it has some proactive features, not just informational aspects.
I think anyway, you know, if you run a profiler, it'll show you where your code's spending time,
but it doesn't mean you should go change everything to make it faster.
You should look at like, oh, well, this loop or this one function is like the thing that maybe
we should think about slightly changing the algorithm or the way we do a loop or something.
And it's a little bit similar here because the specializing adaptive interpreter only specializes
some things like it doesn't specialize floats interacting with ints or those types of things.
And, or I think division as well.
And so there's certain ways you might be able to slightly change inside of a really hot loop,
you know, make something to float ahead of time.
If you know, it's going to be involved in floating point operations.
Right.
Yeah.
The idea is that this is show us how we can fix things so that you don't need to mess with
your code.
I see.
So this is in the future.
Okay.
Yeah.
Awesome.
I would not necessarily encourage people to start tuning individual bytecode instructions
in their code due to our implementation details.
Otherwise you will end coding in C.
You all mean I need to, I got to take all those decimal points back out of my code.
No, just kidding.
Yeah.
I want to get every single bytecode instruction green.
Some things will never specialize and that's just an artifact of programs.
But, you know, if we can specialize enough and we typically do, you know, one line, maybe
20 bytecode instructions if, you know, four of them get specialized successfully and two
of them don't generally, that will still be faster.
Do you know what you should do for April Fool?
Like you should do a pytest plugin that shows you the percentage of specialized instructions
in your code and people can fix the percentage so they can say, fail my test suite if my code
is not specialized more than 50%.
If you de-specialize it, it's like a performance regression.
Drop it.
Yeah.
It's like a coverage thing.
Yeah.
No, I was kind of thinking about this.
So Pablo can tell you more about this, but his cool new tracebacks, the whole reason
specialist is able to do these cool, you know, column level highlighting of your source code
is because we do have that fine grain position information under the hood.
So it's, we kind of just piggybacked on that feature in order to give you that.
But I was kind of thinking another, another thing, another April Fool's project could
be, you know, column level coverage information.
So to get to a hundred percent coverage, you have to cover every single column.
Exactly.
Yeah.
I feel like people might take that too seriously.
Even the white space, all this white space is not covered.
Yeah.
You think you're intense by having branch coverage turned on, just wait till you have column coverage
turned on.
Yeah.
You can only cover two white spaces per line.
So you got to call that a lot.
All right.
I think that's a perfect segue over to one of the most tangible contributions from Pablo
here.
Maybe tell us about this new fine grained error locations and tracebacks.
This is fantastic.
This will save people being in debuggers or rewriting their code with tons of print statements to
figure out what's going on.
Yeah.
Thank you very much.
We put a lot of effort into this.
So this is a man.
I don't even remember my pep.
So I don't know.
It's PEP something, something.
And it has a horrendous name.
Six, five, seven.
And let's see.
Six, five, seven.
Thanks.
Include fine grained error locations and tracebacks.
Yeah.
The worst name.
Even I think I was talking with Mark in the Python code of press print.
And he was saying like, what it means like fine grained, like, you know, like, is this
very fine grained?
Like, so I think we are renaming the PEP to fancy tracebacks.
I think that's much better.
Anyway, so this is a project I worked together with Batuhan, Tazkaya, and Omar Azkar.
So kudos to them as well, because they participated equally on this.
And the idea is that we were like, we started this project to make, you know, to improve the
error messages in the interpreter and the general experience.
Not only for, you know, people, because when people talk about this, they normally refer
to people starting to learn Python.
But like, to be honest, most of these things also affect people that are experts.
Like, I always say that when I implemented the suggestions, I was the first one benefiting
from them because like, I make a lot of typos and, you know, like, this is odd.
You mean this?
So the idea that we have is that most of the time, the lack of, you know, the interpreter
shows you kind of the position when the error happens, but it's quite limited because
most of the time you people tend to have due to Python flexible syntax, a huge amount of
like complexity, even in a single line.
In the pep, there is a bunch of examples.
Like you access a bunch of keys in a dictionary and some of them doesn't work or is not there
or is none or something like that.
Right.
And then it fails.
Or sometimes you have like several function calls or several additions.
And, you know, it's quite difficult.
And most of the time fixing these things involve going into a debugger like PDB and then trying
to inspect every single object and say, okay, this dictionary doesn't have this key at this
level.
And like, you know, that sucks.
Like it's not because like the buggers are cool, but like it's cooler not to use them.
Right.
And, you know, we thought, what can we do here?
And we, we arrived to this idea actually also to mention, everyone involved, this was
originally inspired by some kind of prototype that car from the pipe I team made very long
ago when he saw like a kind of minimal version of this.
And then I said, okay, can we do this?
And what we do now is that we propagate because the parser, our super cool PEG parser knows
position of all the tokens and things like that.
So we are propagating those, that information through the interpreter and we store this information
now in code objects.
So aside the fact of this PEG actually is that code objects are slightly bigger, although,
you know, because code objects don't tend to be a huge percentage of your application.
It doesn't really matter that much.
Maybe PYC files are a bit bigger, but you know, you have a lot of this disk space, I'm
sure.
And the idea is that, you know, we, we store this information in code objects.
So when you raise an exception, we say, well, what is the instruction that is raised this
exception?
And then once we know which is the instruction that raised the exception, then we go and say,
okay, what is the position information that generated this instruction?
And because we propagated it, we know, and then we can say, okay, here is kind of like
the, like the lines, the columns that this instruction spans.
So that kind of allows us to underline the specific location, but we go a bit further.
Oh, sorry.
Sorry.
Go ahead, Michael.
I was going to say, this is super valuable.
The example you have in the PEP is you have a dictionary, you say bracket of key A, and
then the thing that comes back is another dictionary.
So you say bracket B and then another dictionary, bracket C and then bracket D.
And if you own three 10, the error is just like, if one of those is miss is, is, is none,
say none type is object.
Object is not subscriptable, or maybe, you know, does not contain that key or some weird thing
like that.
But is it A, B, C, or D?
You have no idea.
You're in a debugger printing them out separately or something, but now it just goes, nope, it's
the C one.
That's it's the third.
Exactly.
Subscript one.
And that's just, just jump right to it.
Oh, okay.
Yeah.
Also this error, none type is not subscriptable.
It's kind of like, thanks for the info.
Like, it's like, you know, water is wet.
Okay.
Thanks.
It's not, it's not super useful.
No, exactly.
So tell me when it's going to rain.
Anyway, we did like the first version of this and then we realized, realized that there was
some kind of like, you know, it was cool.
Like most people really like it, but like, especially for instance, with the example, with the dictionary
that has many dictionaries inside.
There was some confusion because like, you know, it underlines the whole thing.
And then, you know, the order of operations and, you know, also with complex mathematical
expressions, like you do a plus b plus c and the last addition fails.
It needs to underline a plus b plus c because what happened is that it first added a plus b
and that gives you something that then you added to c.
And what happened is that the last addition failed, but that includes a plus b.
So you need to underline the whole thing.
If you know the order of operations and I just underline a plus b plus c, you know that
what will fail is the last one because that's the last one that is executed.
But it's still confusing because, you know, specifically also with the dictionary, people
were saying, yeah, okay, but like you're underlining three keys here, which is the one that failed.
I mean, you know, you can learn by experience that is the last one, but it's kind of like,
it was not a great experience.
So we went a step farther.
So what we do is that once we know the kind of range in the line that shows the problem,
we reparse that chunk of expression.
And then we know, okay, so we know now that this expression has this AST.
And then we analyze the AST and then we say, okay, is this AST something that we can further
improve the error message?
Like for instance, is this AST a bunch of key access in a dictionary or a bunch of attribute
access or a bunch of function calls or maybe binary operations?
And if it's the case, then we use a specialized, like, you know, on the line, I don't know,
tildes or squiggles or whatever it's called.
And, you know, the dictionary ones have this different one that marks which key access it
was known, the same thing for binary operations and things like that.
So we do this extra step at the end that, you know, does a bunch of extra work, but it
tries to improve even upon the kind of just underlining the line just so we can offer even more
rich information.
And I'm quite happy.
I'm very pleased about this.
Sorry, Mark, but I think it's the best feature of 3.11.
Yeah.
This is probably the second stream when I said this, but it's true.
Totally, totally true.
100% true.
So I'm very excited about this.
I literally use this every day.
Today I was deploying Python 3.11.
Well, this week, sorry.
I was deploying Python 3.11 at Bloomberg and something went wrong.
And literally, this thing saved my day.
This thing saved me to just logging into some forsaken machine and understanding what's going
on.
What about that?
So super cool.
Very happy.
I hope that everybody that uses this and is happy reach to us and say, I am happy.
Because normally people reach to us when they are not happy.
And they say, evil core developers, you break everything.
But instead of that, you should reach to us and say, nice.
I did this cool thing.
You should tweet at Pablo or something, though.
Don't open issues saying you're happy.
Exactly.
Just tweet a couple of tildes if you care.
It's in a smiley face, Adam.
Exactly.
Tweet happy at python.org.
I will take that email address.
Awesome.
It's that we improve it a bit further.
One of the things that happen is that, you know, like sometimes if the whole line is wrong,
because this example you have there, if you, sorry, for the ones listening to the podcast,
we have here some, we are seeing some output, but doesn't matter.
Don't worry.
I will describe it.
So, for instance, you're calling a function and that's the whole thing that is in the line.
We used to underline the whole thing.
So, we'll say, okay, even if the whole line is failing, so it's not like a part of the line is failing,
the whole thing is failing, we used to underline that.
And that apparently is still on the pep.
Maybe I should change that because that is not like that anymore.
Because someone suggested, I mean, come on, like if it's the whole line is failing,
underline the whole line is actually not that useful.
And, you know, you are spending vertical space.
So, you need to scroll a lot.
And at the beginning, I say, yeah, but it's inconsistent.
I don't like it.
And I push back a bit, but like then, you know, more people say, Pablo, you're wrong.
And then I say, okay, okay, I'm wrong.
We improve this further.
So, you say, but don't take this as an advice.
Don't tell me that I'm wrong collectively, please.
But, right, so now if the whole line is underlined, we don't underline it
because it doesn't really add any new information, right?
So, only if a part of the line contains the error and not the whole line.
So, this means that we are not going to, you know, consume a lot of vertical space for no reason.
And the last thing I wanted to say is that, you know, there is some people somewhere in the universe
that may care about that extra disk space on their PYC files, or they just really, really hate squiggles.
I don't know if that is even physically possible, but, you know, there are very different and diverse set of people.
You are one of those.
There is a collection of different ways you can deactivate this feature.
There is an environment variable with a super long name, and there is minus X option when you launch the interpreter.
So, you can say Python minus X something, something.
I don't know how it's called.
I think it's called no the back ranges.
What about that?
What an incredible naming.
And then you set no the back ranges to one, and it deactivates the feature.
Incredible.
Like magic.
It's gone.
And you can reclaim your PYC files, and you can even generate PYC files without this information
if when you are compiling PYC files, you set this evil variable variable.
But don't do that, listeners.
Don't do that.
It's evil.
Don't do that.
Just use it.
It's great.
Yeah.
There's another kind of type of errors that I think we're going to get is about edge cases
where the compiler doesn't get the line numbers right, because all these kind of fine-grained
locations, it's all new.
And, you know, we're still ironing out.
The front future.
There is a front future, I think, that you put like a bunch of things with the front future.
It just complains on a random place.
Yeah.
Today I found that one.
I've been looking at the compiler and line numbers, location information, and it's a
bit off here and there.
And we have received bug reports from other people as well.
The range here doesn't look right.
The range here looks too broad.
So, yeah, we're going to be ironing that out, I guess, for 312s.
Yeah, it's really nice when people are using betas and release candidates, though, because
we were able to catch a lot of those before the release.
Because there were a couple people, I forget exactly the name of the project, but they were
working on like a code animation tool where it animates your code while it's running.
And they were using these new ranges to identify AST nodes and stuff.
And so they did this thing, I guess, where they like run their tool on the entire standard
library, make sure it's correct.
And so we got a bunch of bug reports that basically say, oh, you know, this column information
is off for this weird multi-line attribute access or something.
If you recall, I think you fixed an error.
That was super weird because it was like a method access, like, you know, my instance of
full.
And if the method access has like some like vowel or something like that, it was wrong.
And if you added some extra letter, it was fine.
Yeah, it was like if you split your method access across two lines, if you do like x dot
method or x dot method or x dot method on three lines or two lines or something, the way
we trace those lines, we always trace the method when we're actually loading the method, even
if it's on a different line, it's like where the actual method load started.
And then we were doing some weird math to like figure out where the dot is.
So we would try to put it on the same line as the dot.
And so we just like subtract one from the length of the name.
So there's all sorts of crazy stuff.
And that came from the grave because we fixed that.
And then it was wrong again because like we were like miscalculating the name.
It's just so easy.
Oh my goodness.
Yeah.
So all sorts of fun stuff like that.
Yeah.
Amazing.
Well, yeah, this is definitely one of the highlight features for sure.
And also the performance work that you're all doing.
All right.
We're getting very, very short on time.
So I think maybe a super, super lightning round here.
Let me just say we also got Tomolib support built in.
We've got the asyncio task groups a la trio nurseries.
We've got new features for atomic grouping and regular expressions, a self-type.
A lot of type things have been added.
So we've got the self-type, bariatric generics, literal strings, which is very interesting.
Lukash did a talk about that on the release live stream.
Stuff for type dict and data class transformations.
So great stuff.
Now let's just really quickly round out.
What's the Python 3.11 story for PyScript, Pyodide?
Is there, do you know, have anyone out there know?
I don't know.
I suppose it works.
I think WebAssembly is now a tier two or tier three supported platform, right?
So he has been making a lot of improvements to the build process, which, you know, is not easy.
So kudos to Christian Himes.
If you're listening, you're great.
I suppose that PyScript can, through Pyodide, this is how many layers is this?
So Pyodide through this can leverage all these improvements because I don't know how the whole
layer that word thing is working, but Pyodide has a bunch of patches that, you know, you
need to modify CPython so it builds nicely on WebAssembly platforms.
I don't know the details on that.
I just know that some of them are okayish.
Some of them are not okay and quite difficult to maintain.
And Christian Himes has been making a lot of great effort to, you know, change here and
there and like put a lot of macros and if devs and things like that.
So CPython kind of builds easier.
This probably translates that Pyodide, I hope, kind of, you know, can consume this build in
an easier way with less patches.
And I suppose that translates into PyScript, like just using the Pyodide thing easier.
But yeah, I don't think that there is a huge amount of improvements more than, you know,
we are working towards official support as Brian was mentioning.
We have this next year system.
It's super cool.
And as like an unrelated fun fact, Mike Drapu, one of the early developers of Pyodide,
is actually managing our team at Microsoft.
Oh, it's funny how the circle comes back around indeed.
How the darn tables.
That's right.
All right.
We are out of time, but super exciting.
I wish we had some champagne.
And Pablo, we didn't even bring hats to celebrate Python 3.11.
But I know everyone out there is extremely excited.
People cannot see it, but they have a Python 3.11.
Yes.
Yeah.
It's a great new logo for 3.11 and stuff.
Not for in general, but just for the release.
It's awesome.
All right.
Before we get out of here, let me just ask you one final question and then we'll call it
a show.
Notable PyPI package.
Something you want to give a shout out to.
We'll go top to bottom in the picture here.
Pablo?
Notable PyPI package.
And I'm going to say memory.
Use memory.
The one and only Python memory profiler.
Solve your problems on production today with memory.
That and the underlying errors, you'll be all good.
Exactly.
Yeah.
A combination.
Arit, how are you?
Well, I've had some interaction with the author of bytecode, Ration King, because I was
looking at things to do in the testing and in the interpreter that are kind of like that.
So this is a library you can kind of from Python write bytecode and it's pretty neat.
And it's struggling with zero cost exceptions, but that's what it is.
It's like inline assembly, but for Python.
Yeah.
It's like from a Python script, you can kind of write a bit of bytecode and get it to,
I don't know, do a lot of interesting stuff.
That's awesome.
Brent, how about you?
Well, I'm partial towards specialist, but if I had to choose something else, speaking
of speed, I really like the scaling profiler.
I've been using it a lot of my own projects and it's awesome.
I don't know how it's memory profiling compares to memory.
I'm sure memory is better, but scaling is really nice for measuring the performance across
both Python and C code, which is cool.
Excellent.
Mark?
Well, it's not actually a PyPI package.
I was going to say the sys module, which is pretty much the most fundamental module going.
Come on.
There's all sorts of fun things in there.
You can change the recursion limit and C.
You can muddle it.
If you're interested in how Python works, it's actually quite a sort of fun thing to play with.
Thank you all for all the hard work.
And I know there are many people who did a ton of work as well who are not on the show here,
but you can represent them as well.
So thanks all for being here.
Final call to action.
People want to get started at 3.11.
What do you tell them?
Is it ready for them to get going?
What do you think?
It's awesome.
And also now 3.11 comes with a bunch of wheels for all your packages because there has been a lot of good work in the people of third-party libraries.
And now that people are using CI build wheel, 3.11 was released with wheels for NumPy and Pandas and a bunch of other things that previously was failing massively because nobody could compile them on their crappy laptop.
But now you don't need that.
You can just download them and it works.
So just use 3.11.
There is no reason.
Yeah, that's excellent.
It's just boring.
That would be a reason.
If you're boring and you don't want to use 3.11, then don't use it.
You didn't break anything.
Not even a package, much less GitHub.
Right.
And we need more benchmarks.
Well, that's true.
Yeah, absolutely.
That's how people can help us make things faster.
There's more benchmarks.
So, yeah, we have a, there's a sort of standard Python performance suite, but it's kind of a bunch of toy programs and so on.
So if you've got something that might make a nice sort of benchmark, you know, sort of self-contained but sort of realistic program, then, yeah, let us know.
All right.
Cool.
Well, thanks again.
Great work on it.
Cam Gearlock out in the audience says, yay, CI Buildwheel.
Yeah, absolutely.
Great stuff.
So thanks again, everyone.
I'm super excited to start using 3.11 myself.
Thank you, Michael, for inviting us.
Yeah, it's great to have you here.
Thank you.
Bye, all.
This has been another episode of Talk Python to Me.
Thank you to our sponsors.
Be sure to check out what they're offering.
It really helps support the show.
Take some stress out of your life.
Get notified immediately about errors and performance issues in your web or mobile applications with Sentry.
Just visit talkpython.fm/sentry and get started for free.
And be sure to use the promo code talkpython, all one word.
Command Line Heroes is an original podcast from Red Hat that chronicles the history of the software industry.
From the origins of the first high-level programming languages to Python's tale, each episode is a fascinating look back at how we got to where we are.
Listen to an episode at talkpython.fm/heroes.
Want to level up your Python?
We have one of the largest catalogs of Python video courses over at Talk Python.
Our content ranges from true beginners to deeply advanced topics like memory and async.
And best of all, there's not a subscription in sight.
Check it out for yourself at training.talkpython.fm.
Be sure to subscribe to the show, open your favorite podcast app, and search for Python.
We should be right at the top.
You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the direct RSS feed at /rss on talkpython.fm.
We're live streaming most of our recordings these days.
If you want to be part of the show and have your comments featured on the air, be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Now get out there and write some Python code.
See you soon.
Thank you.