Latest / Talk Python To Me / #381: Python Perf: Specializing, Adaptive Interpreter
Transcript
- 0:00We're on the edge of a major jump in Python performance.
- 0:03With the work done by the FasterCpython team and Python 3.11 due out in around a month,
- 0:08your existing Python code might see an increase of well over 25% in speed with no changes to your code.
- 0:15One of the main reasons is its new specializing adaptive interpreter.
- 0:19This episode is about that new feature and a great tool called Specialist,
- 0:23which lets you visualize how Python is speeding up your code and where it can't unless you make minor changes.
- 0:29Its creator, Brant Booker, is here to tell us all about it.
- 0:32This is Talk Python To Me, episode 381, recorded September 15th, 2022.
- 0:37Welcome to Talk Python To Me, a weekly podcast on Python.
- 0:53This is your host, Michael Kennedy.
- 0:54Follow me on Twitter where I'm @mkennedy and keep up with the show
- 0:58and listen to past episodes at talkpython.fm.
- 1:01And follow the show on Twitter via at Talk Python.
- 1:04We've started streaming most of our episodes live on YouTube.
- 1:07Subscribe to our YouTube channel over at talkpython.fm/youtube
- 1:11to get notified about upcoming shows and be part of that episode.
- 1:14This episode is sponsored by Microsoft for Startups Founders Hub.
- 1:18Check them out at talkpython.fm/founders hub to get early support for your startup.
- 1:24And it's brought to you by compiler from Red Hat.
- 1:27Listen to an episode of their podcast as they demystify the tech industry over at talkpython.fm/compiler.
- 1:35Brant, welcome to Talk Python To Me.
- 1:37Thank you for having me.
- 1:38I'm excited to talk about some of this stuff.
- 1:39I am absolutely excited about it as well.
- 1:42I feel there's a huge renaissance coming, happening right now,
- 1:46or has been happening for a little while now around Python performance.
- 1:49It's exciting to see, especially in just the last couple of years,
- 1:53that you definitely see these different focuses,
- 1:55whether it's, you know, improving single-threaded Python performance,
- 1:59multi-threaded Python performance, you know, Python in the browser.
- 2:02There's a lot of really cool stuff happening, right?
- 2:04Yeah.
- 2:04Oh, if we could talk WebAssembly and PyScript and all that,
- 2:08that is a very exciting thing.
- 2:09There's probably some performance side around it,
- 2:11maybe something we could touch on,
- 2:13but that's not the main topic for today.
- 2:14We're going to talk about just the core CPython
- 2:16and how it works, which is going to be awesome.
- 2:19Some work you've done with the team there at Microsoft
- 2:21and your contributions there.
- 2:23Before we get into all that stuff, though,
- 2:24let's start with your story.
- 2:26How did you get into programming in Python?
- 2:27Yeah.
- 2:27So I originally studied computer engineering,
- 2:31so like hardware stuff at UC Irvine.
- 2:34Around my, like, third or fourth year, so like 2017,
- 2:37I encountered Python really for the first time
- 2:41in like a project setting.
- 2:42Basically, it was a senior design project.
- 2:44We get to kind of make whatever we want.
- 2:46So we made this cool system that basically it's point cameras
- 2:50at a blackjack table and it's X card counters.
- 2:52And if you want to do something like that in, you know,
- 2:54four months or whatever, Python is kind of the way to go.
- 2:57Yeah, the CV stuff there is really good, right?
- 2:59Yeah.
- 3:00So it was NumPy and OpenCV,
- 3:01and that was kind of my first exposure to this stuff.
- 3:03And so I learned that I like developing software
- 3:07a lot more than developing hardware.
- 3:08So I kind of never looked back and just went full in.
- 3:13About a year later, so like 2018,
- 3:15I opened my first PR to the CPython Red Belt,
- 3:19and it was merged.
- 3:20And you're up to that.
- 3:21What was that PR?
- 3:22Oh, there's this standard library module
- 3:26called Module Finder.
- 3:27Basically, it's one of those ones
- 3:30that's kind of just a historical oddity,
- 3:32and it's still in there.
- 3:33Basically, you can run it over any Python script.
- 3:36It detects all the imports,
- 3:37and so you can use it to build an import graph.
- 3:39And I forget exactly what I was using it for.
- 3:41I think it was for work.
- 3:42And I ran into some bugs that had been just kind of lingering there for years.
- 3:46And so I, you know,
- 3:48submitted patches for a bunch of them.
- 3:50And so that was kind of my first experience contributing to open source in general.
- 3:54That PR was actually open for a while.
- 3:57It was open for like, I think it was like a month or two or something like that.
- 4:02So in the meantime, I contributed other things to like my Pi type shed,
- 4:06but that's still my first open source contribution.
- 4:09It counts the day it was open.
- 4:10Yeah, it counts as a beginning or the end of the PR, right?
- 4:14Yeah, exactly.
- 4:15Because those can be very different things sometimes.
- 4:17They can be very different.
- 4:18You know, we have now in CPython,
- 4:20we have the, just in Python, I guess,
- 4:22we have the developer in residence with Lucas Schlinger.
- 4:25He's there to sort of facilitate making that a lot faster.
- 4:28And I feel like people's experience there might be picking up speed and improving.
- 4:32Yeah, no, I think that's a great thing.
- 4:34And in general, just seeing this kind of shift towards full-time Python core development,
- 4:38you know, being funded by these big companies is really exciting to see.
- 4:43I think it improves the end contributor experience, the user experience,
- 4:47and just gets things done, which is nice.
- 4:49I don't have any numbers, but I imagine there are fewer of those kind of lingering,
- 4:53you know, months old PRs than there were back when I first started.
- 4:57Yeah.
- 4:58Way, way long ago, four years ago.
- 5:00So far back in the past.
- 5:02So long, so long, yeah.
- 5:04So yeah, so that was like 2018, 2019,
- 5:07I became a member of the triage team,
- 5:10which is basically a team for people who are kind of more involved in Python
- 5:16than just your average drive-by contributor.
- 5:18So while they're not full core developers,
- 5:20they basically can do anything a core developer can,
- 5:24except vote and actually, you know, press the merge button.
- 5:26So that was really nice because it made doing things like reviewing PRs easier.
- 5:30Tagging issues, closing issues, that sort of thing.
- 5:34A year later, I became a core developer.
- 5:36How did you get the experience for that?
- 5:37Like, how do you, you know, it's one thing to say,
- 5:39well, I've focused on this module and here's this fix.
- 5:41And it's another to say, you know, give me anything from CPython and I'll assess it.
- 5:45Well, it wasn't give me anything from CPython.
- 5:47And it was, you know, made it part of my morning routine to, you know, wake up,
- 5:51go to a coffee shop, order a coffee, and just for a half hour, look at newly opened issues.
- 5:57And for newly opened PRs.
- 5:59Yeah.
- 5:59Yeah.
- 6:00Well, I focus mostly on PR review for new contributors.
- 6:03Basically, I had filters set up that said, you know, show me all the PRs open the last 48 hours from a new contributor.
- 6:09I thought, okay, my first contribution experience wasn't that great.
- 6:12It'd be great if these people who have never opened a PR to CPython before can get a response within 48 hours.
- 6:18Whether that's telling them to sign the contributor license agreement or formatting fixes or pinging the relevant core dev or whatever.
- 6:24So that was kind of how I dove into that.
- 6:27All this terminology that you're using, PRs and stuff.
- 6:30No, this is great.
- 6:31What I was going to say is that this is new to Python, right?
- 6:35It wasn't that long ago that Python was on Mercurial or before then Subversion.
- 6:40It's, you know, it's coming over to GitHub is kind of a big deal.
- 6:43And I feel like it's really opened the door for more people to be willing to contribute.
- 6:47What do you think?
- 6:48Oh, it absolutely lowered the barrier to entry for people like me.
- 6:51Like using the old bugstoppython.org was tough at first, but I eventually kind of got used to it just in time for it to be replaced with GitHub issues, which I much prefer.
- 7:01But I have a hard time seeing myself emailing patches around or, you know, I have a lot of respect for people where that was the development flow a number of years ago.
- 7:10So I became a core developer in 2020.
- 7:14And I guess it was about exactly a year ago, almost exactly a year ago, I joined the Python performance team here at Microsoft.
- 7:21Were you at Microsoft before then?
- 7:23No, I was not.
- 7:24I worked for a company called Research Affiliates in Newport Beach.
- 7:28And I think you actually had my old manager, Chris Ariza, on the show a couple years ago.
- 7:33I have had Chris on the show.
- 7:34That's fantastic.
- 7:34Small world, huh?
- 7:36Yep.
- 7:36Small Python world.
- 7:37Yeah, small Python world.
- 7:39Just a couple million of us.
- 7:40No, that's great.
- 7:42So this brings us to our main topic.
- 7:45And, you know, let's start at the top, I guess.
- 7:49You know, there's the faster Python team, I guess.
- 7:52I don't know.
- 7:53How do you all refer to yourself?
- 7:55Yeah, we refer to ourselves as the faster CPython team.
- 7:58I think internally our distribution list is the CPython performance engineering team, which sounds a little gnarlier, but it's a lot wordier.
- 8:06That's a cool title to have on a resume, isn't it?
- 8:09Yeah, I think I'll use that one.
- 8:11There you go.
- 8:12There's been a ton of progress.
- 8:14And some of this work was done in 3.10.
- 8:17But, you know, there's this article here that I got pulled up on the screen.
- 8:21It says, Python 3.11 performance benchmarks are looking fantastic.
- 8:25That's got to make you feel good, huh?
- 8:27I mean, they were looking fantastic back in, what, June?
- 8:29Yeah.
- 8:30They're a small bit more fantastic now.
- 8:33So, yeah.
- 8:33Yeah, exactly.
- 8:34This article's from June.
- 8:35So this is a, it's only better from here, you know, from there, right?
- 8:38It's really exciting.
- 8:40And like I said, it's, this is a performance jump that at least since I've been involved in Python, we haven't seen this in a point release.
- 8:47You know, where we're seeing 25, 30%, sometimes more improvements for pure Python code rather than kind of the 5, 10, 15% range that might be more typical.
- 8:58And again, I think that's kind of a product of this very conscious effort, whether it's my team or that a lot of people that we interact with.
- 9:07So, for example, Pablo, release manager, strength council member at Bloomberg has been working a lot on this stuff with us.
- 9:14Outside contributors, do they come to mind or Dennis Sweeney, Ken Jin.
- 9:19There's definitely been a focus on this and it's paying off, which is really exciting, like I said.
- 9:24Yeah.
- 9:24And maybe a little bit more in parallel instead of a cooperative effort, but there's also the Cinder folks over at Meta Facebook.
- 9:32That's absolutely a cooperative effort.
- 9:34You know, even though Cinder isn't necessarily, we're not merging all of Cinder back into CPython, several of the changes are being upstreamed into CPython.
- 9:44And in fact, just earlier this week on Tuesday, we had, I think, like a two-hour meeting where the Cinder team walked our team through how their JIT works.
- 9:52Yeah.
- 9:53So it's, even though, yeah, it can be seen as a parallel effort, I think it's very collaborative.
- 9:57I think also, I, like you, am very much blown away at the step size of the performance improvements.
- 10:04It's just super surprising to me that a 30-year-old language and a 30-year-old runtime can get that much better in that short of a time.
- 10:12Yeah.
- 10:12And I think, again, I feel like I'm going to keep coming back to this, but having, you know, full-time people dedicated to this, having teams of people dedicated to this, I think that's a big part of sort of unlocking this.
- 10:24Because some of the things that are required for those big jumps are kind of larger architectural changes that, you know, a single volunteer who's, you know, doing this on their free time probably wouldn't have been able to do without coordinating with others and without throwing, you know, a significant amount of effort at it.
- 10:41Yeah.
- 10:41I mean, there are people out there, core devs, who have done amazing stuff.
- 10:44Shout out to Victor Stinner.
- 10:46I feel like a lot of the performance stuff that I've seen in the last couple of years, he is somehow associated with, you know, some major change.
- 10:53But the changes that are being undertaken here, they're much more holistic and far-reaching.
- 10:59And it really does take a team, I think, to make it reasonable, right?
- 11:03What's cool about the 3.11 effort is it's a combination of kind of both sorts of changes.
- 11:07So we have, you know, a bunch of kind of one-off, very targeted changes, probably five or six or ten of those.
- 11:15And then we have, you know, one or two of these kind of larger changes that, you know, we can build upon in the future.
- 11:21And they're never really done, which, you know, that's exciting because it means we get to keep making Python faster.
- 11:28Yeah.
- 11:28It is exciting.
- 11:29I think another area to just highlight real quick before we get into too much detail is, correct me if I'm wrong, but none of this is particularly focused on multi-core parallelism, right?
- 11:41No.
- 11:41So one member of our team, Eric Snow, he's basically the sub-interpreter guy.
- 11:46Exactly.
- 11:46Yeah.
- 11:47So he is focusing most of his time on, you know, a per-interpreter kill and, you know, all that sort of stuff.
- 11:55But, I mean, all the numbers that you're looking at here and all of our benchmarks, it's all single-threaded, single process.
- 12:02If you're running Python code, it will get faster without you changing your code, which is awesome.
- 12:07Yeah, it's super awesome.
- 12:09I want to highlight that because if Eric manages to unlock multi-core performance without much contention or trade-offs or, you know, if you've got an eight-core machine and you get 7x performance by using all the cores, like, that would be amazing.
- 12:23But all of this work you're doing applies to everyone, even if they're trying to do that stuff, right?
- 12:28So even if somehow we get this multi-core stuff, the computational multi-core stuff working super well, the work that you're doing and the team is doing is going to make it faster on every one of those cores, right?
- 12:38So they're kind of multiplicative initiatives, right?
- 12:41So if we could get a big improvement in the parallel stuff, it's only going to just multiply how much better this aspect of it's going to be for people who use that, right?
- 12:49It's great to be kind of pursuing all these different avenues because they pay off in different timeframes, right?
- 12:54Some of these are longer efforts.
- 12:56And in Eric's case, the 7x program for very long effort.
- 12:59I think he's done a great job sticking with it and seeing it through.
- 13:03And some of these we're seeing in point releases.
- 13:05And so they absolutely build on each other.
- 13:09Like you said, you can get a 7x increase from sub-interpreter just to throw out a number.
- 13:13But Python as a whole got 25% or 30% faster than you're seeing much more than a 7x increase.
- 13:18Right.
- 13:19Absolutely.
- 13:19So very, very exciting times.
- 13:21Two things before we get into the details of a particular interpreter and stuff.
- 13:26Tell me a bit about this team.
- 13:27You know, I interviewed Guido and Mark Shannon a while ago, about a year ago, I suppose, about this plan when they were kicking it off.
- 13:35And we didn't have these numbers or anything, but we did talk about what we were doing.
- 13:39And he talked about the team that he's working with there.
- 13:41So he said, certainly it's just more than the two of us.
- 13:44You know, tell us about the team.
- 13:45Yeah.
- 13:46So I think there are seven people.
- 13:49So there's Guido and Mark, Eric and me, as we mentioned.
- 13:52Another core developer, Urit.
- 13:54One other engineer, El.
- 13:56And a manager for the team who also does some engineering effort as well and is a member of the triage team, Mike Dronfum.
- 14:04Yeah.
- 14:04Nice.
- 14:05Yeah.
- 14:05Yeah.
- 14:05He worked on Pyoxidizer.
- 14:08Pyodide.
- 14:09That's right.
- 14:09Pyodide.
- 14:10Yeah.
- 14:10I don't know why.
- 14:11It's a pie.
- 14:13There's some kind of like a molecule on the end.
- 14:16Exactly.
- 14:16Exactly.
- 14:17Pyoxidizer.
- 14:18That's right.
- 14:18That's the foundation for PyScript, actually, which is quite cool.
- 14:22Py3 is cool too.
- 14:23The other question.
- 14:24Yeah.
- 14:24Yeah.
- 14:25Yeah.
- 14:25Yeah.
- 14:25Yeah.
- 14:25The other thing that I want to ask you about is, so we have these numbers and visibility into Python 3.11 that's got a lot of conversations going.
- 14:35And people are saying they're looking amazing and fantastic and other nice adjectives.
- 14:39But this is in beta, maybe soon to BRC.
- 14:42I'm not sure.
- 14:43What is Python 3.11 status these days?
- 14:463.11, we just released our last release candidate, I think this week.
- 14:52Right.
- 14:52So this, if basically the idea is this, the final release candidate and the actual 3.11 release should be the exact same thing.
- 15:01Unless we find any serious bugs that we're fixing before 3.11 won, the release candidate is going to be 3.11.
- 15:10Awesome.
- 15:10This is as close to stable as any of the releases.
- 15:13Almost there, right?
- 15:14Okay.
- 15:14Yeah.
- 15:15Cool.
- 15:15So the reason I ask that is a lot of the work you've been doing recently is probably on 3.12, right?
- 15:20Yes.
- 15:20Yeah.
- 15:21So beta freeze, which is basically when we go from alphas into betas, and there's no more basically new features allowed at that point.
- 15:29That happens every May.
- 15:30And so everything that we've been working on since May goes into 3.12.
- 15:35Are you excited about the progress you've made?
- 15:36Yeah.
- 15:37Yeah.
- 15:37Very excited.
- 15:38It seems to be still coming along well.
- 15:39Yes.
- 15:39Yeah.
- 15:40And it's nice.
- 15:41We still have a lot of time before the next beta.
- 15:43Let's talk really quickly about the faster-cpython thing put together by Mark Shannon.
- 15:48Guido called it the Shannon plan.
- 15:50And the idea is, how can we make Python five times faster?
- 15:54If we could take Python and make it five times faster, that would be a really huge deal.
- 15:57And again, none of that is multi-core.
- 16:00If you could somehow unlock all the cores and you've got eight, that's 35 or 40 or something like that.
- 16:07This is an ambitious plan.
- 16:09It started out with a little bit of work with 3.10.
- 16:12Is that when the adaptive specializing interpreter first appeared, or did it actually wait until 3.11 to show up?
- 16:18No, I don't believe we.
- 16:20We don't have it at 3.10.
- 16:21Yeah, I didn't think so either.
- 16:22Missing something.
- 16:23Yeah.
- 16:23Yeah.
- 16:24So that's in 3.11.
- 16:25The rest of it looks accurate, though.
- 16:26Yeah.
- 16:27So then basically that was stage one.
- 16:29Stage two is 3.11, where there's a bunch of things, including kicking over the interpreter.
- 16:34We're going to talk about the specializing interpreter.
- 16:37A bunch of small changes here.
- 16:38And then stage three for 3.12 is JIT.
- 16:42Have you guys done any work on any of the JIT stuff?
- 16:45Right now, it's not looking like 3.12 will ship with a JIT.
- 16:49We think there are other changes that we can make that don't require a JIT that will still pay off.
- 16:56We're probably planning on at least experimenting with what a JIT would look like.
- 17:01Like I said, we already have gotten kind of a guide towards Cinder's JIT.
- 17:04And so we're talking kind of high-level architecture and prototyping and that sort of thing.
- 17:08But I would be surprised if 3.12 shipped with JIT.
- 17:13But it's a long effort.
- 17:16So starting now is a big part of that.
- 17:17Research is being done, huh?
- 17:18Yes.
- 17:19Actively.
- 17:19Yeah.
- 17:19Yeah.
- 17:20Cool.
- 17:20All right.
- 17:21Well, this was put together quite a while ago, back in 2020, as here's our plan.
- 17:26And of course, plans are meant to evolve, right?
- 17:28But still, looks like this plan is working out quite well because of the changes in performance that we saw already in 3.11 beta.
- 17:35And pretty fantastic.
- 17:37There are a bunch of changes here about things like zero overhead exception handling.
- 17:43I believe there was an overhead for entering the try block.
- 17:47Every time you went in or out of a try accept block.
- 17:51So even if I did try pass, accept pass, there was overhead associated with that.
- 17:56Right.
- 17:57So basically, we would push a block that says, oh, if an exception happens, jump to this location.
- 18:03Now what we do is we realize, oh, we actually have that information ahead of time when we're actually compiling the bytecode.
- 18:10So since the common case is that an exception is raised, then we can store that data in a separate table and say, oh, if an exception is raised at this instruction, then jump here without actually having to do any of that management at runtime.
- 18:24So it's a little more expensive.
- 18:27I believe if an exception is raised.
- 18:28But in the case of an exception, it's not raised.
- 18:30I think it is basically as close to truly zero cost as possible.
- 18:36This portion of talk, I think it's a little bit more.
- 18:38This portion of talk, Python to me is brought to you by Microsoft for startups, founders hub.
- 18:41Starting a business is hard.
- 18:43By some estimates, over 90% of startups will go out of business in just their first year.
- 18:48With that in mind, Microsoft for startups set out to understand what startups need to be successful and to create a digital platform to help them overcome those challenges.
- 18:57Microsoft for startups founders hub was born.
- 18:59Founders hub provides all founders at any stage with free resources to solve their startup challenges.
- 19:05The platform provides technology benefits, access to expert guidance and skilled resources, mentorship and networking connections, and much more.
- 19:14Unlike others in the industry, Microsoft for startups founders hub doesn't require startups to be investor backed or third party validated to participate.
- 19:23Founders hub is truly open to all.
- 19:26So what do you get if you join them?
- 19:27You speed up your development with free access to GitHub and Microsoft cloud computing resources and the ability to unlock more credits over time.
- 19:35To help your startup innovate, founders hub is partnering with innovative companies like OpenAI, a global leader in AI research and development to provide exclusive benefits and discounts.
- 19:45Through Microsoft for startups founders hub, becoming a founder is no longer about who you know.
- 19:50You'll have access to their mentorship network, giving you a pool of hundreds of mentors across a range of disciplines and areas like idea validation, fundraising, management and coaching sales and marketing, as well as specific technical stress points.
- 20:03You'll be able to book a one-on-one meeting with the mentors, many of whom are former founders themselves.
- 20:08Make your idea a reality today with a critical support you'll get from founders hub to join the program.
- 20:14Just visit talkpython.fm/founders hub, all one word, no links in your show notes.
- 20:19Thank you to Microsoft for supporting the show.
- 20:21I think that's the way it should be.
- 20:23You know, exceptions, as the word implies, is not the main thing that happens.
- 20:28It's some unusual case that has happened, right?
- 20:31So not always, but often means something has gone wrong.
- 20:34So if something goes wrong, well, you kind of put performance to the side anyway, right?
- 20:39Yeah.
- 20:39Well, and, you know, a lot of the sort of optimizations that you want to see, especially in, for example, JIT code or whatever, exceptions are the sort of thing that mess that up.
- 20:49Where, you know, if an exception is raised, okay, get out of the TUDIC code, go back to slow land where we know what's going on and have better control of context and everything.
- 20:57But yeah, no, it's really exciting to see.
- 20:59It's really cool design.
- 21:01Yeah, it was Mark Shannon who did this.
- 21:03Mark Shannon did a lot of this.
- 21:05There's a bunch of improvements coming along, but what I want to really focus on here is the PEP 659, the specializing adaptive interpreter.
- 21:15And in addition to being on the team, you've created a really cool project, which we're going to talk about as soon as we cover this one, about how you actually visualize this and maybe even change your code to make it faster.
- 21:27Understanding how maybe opportunities might be missed for your code to be specialized or adapted.
- 21:32No, PEP 659.
- 21:34I mean, the concepts are not too difficult, but the implementation is really hairy.
- 21:39So I think it definitely deserves to be gone over 70.
- 21:43Because it's really cool when you get down to how it actually works and what it's doing.
- 21:47Is this the biggest reason for performance boosts in 3.11?
- 21:51I think it's the most important reason for performance boosts.
- 21:54I mean, any performance boost kind of depends on what you're doing, right?
- 21:57Like we did, for example, Pablo and Mark worked together on making Python to Python calls way faster and way more efficient.
- 22:04So if you're doing lots of recursive stuff, that's going to be the game changer.
- 22:07If you spend all your time writing loops that just do try, accept, try, accept.
- 22:12Yeah.
- 22:13That one's better.
- 22:14Yeah.
- 22:15If you're, yeah, got it.
- 22:17Try accept in tight lubes or, you know, if you're, you do lots of regular expressions,
- 22:21then our improvements in that area will probably matter more than this.
- 22:24But this is cool because we can build upon it to kind of unlock additional performance improvements.
- 22:32Sure.
- 22:33We can kind of get to that once we have a better idea of how exactly.
- 22:35When I look at PEPs, usually it'll say what its status is and what version of Python it applies to.
- 22:42And I see this PEP, it doesn't say which version it applies to and its status is draft.
- 22:46What's the story here?
- 22:48I'm actually not sure what the story is behind the PEP itself.
- 22:52I think it's a good informational document that explains, you know, the changes that we did get into Python 3.11.
- 22:58But I don't think the PEP was ever formally accepted.
- 23:02As you can see, it's just an informational PEP.
- 23:05So it's kind of more the design of what exactly we're doing and how we plan to do it.
- 23:09Right.
- 23:10Because it's not really talking about the implementation so much as like, here's the roadmap and here's what we plan to do and stuff.
- 23:17Right?
- 23:18Yeah.
- 23:18There's a lot of pros in there that says, here's how we might do it.
- 23:20But, you know, no promises.
- 23:22We could change this literally anytime.
- 23:24And we have.
- 23:25Yeah.
- 23:25The design has changed fairly significantly since this PEP was first published.
- 23:30But we've updated that so it can remain.
- 23:32Yeah.
- 23:33Cool.
- 23:33Okay.
- 23:34So the background is when we're running code, it's not compiled and it's not static types.
- 23:41Right?
- 23:41It's because it's Python.
- 23:43It's dynamic.
- 23:43And the types could change.
- 23:45They could change because it just uses duck typing and we might just happen to pass different things over.
- 23:50I mean, we do have type hints.
- 23:52But as the word there is, it applies as a hint, not a requirement like C++ or C# or something.
- 23:58You have to have the CPython runtime be as general as possible for many of its operations.
- 24:05Right?
- 24:06Yeah, absolutely.
- 24:06And beyond just types, things like I could create a global variable at any time.
- 24:11I could delete a global variable at any time.
- 24:13I could add or remove arbitrary attributes.
- 24:16All these sort of very Pythonic things about Python or un-Pythonic, depending on how you're looking at it.
- 24:22These are all things that would never fly in pilot length.
- 24:25Yeah, and they mean you can't be overly specific about how you work with operations.
- 24:31So, for example, if you say, I want to work with call this function and pass it the value of X.
- 24:36Well, where did X come from?
- 24:38Is X a built-in?
- 24:39Is it a global variable?
- 24:41Is it at the module level?
- 24:43Is it a parameter?
- 24:45Is it a local variable?
- 24:46All these things have to be discovered at runtime, right?
- 24:49For the most part, yeah.
- 24:50Yeah, for the most part.
- 24:51Part of this adapting interpreter is it will run the code and it says, look, every single time they said load this variable called X, it came out of the built-ins, not out of a module.
- 25:04And so we're going to replace that code, specialize it, or quicken it.
- 25:08I've heard of quickening, so I'll have to work on the nomenclature a little bit there.
- 25:11We can clear up the terms a bit, yeah.
- 25:14Yeah, yeah, but you're going to take this code and you're going to replace it and don't say just load an attribute or load a value from somewhere and go look in all the places.
- 25:22You're like, no, no, no, go look in the built-ins and just get it from there.
- 25:25And that skips a lot of steps, right?
- 25:27Yep, yeah.
- 25:28Or maybe I'm doing math here and every single time it's been an integer.
- 25:31So let's just do integer math and not arbitrary addition operator.
- 25:35With the huge asterisk that if it does become a global variable or if it does start throwing floats at your addition operation, that we don't say false or even produce an incorrect result.
- 25:49Right, because you could say, use x.
- 25:51But before that, you might say, if some value is true, x equals this thing.
- 25:55And it goes from being a built-in to a local variable or some weird thing like that, right?
- 26:00And if it overly specialized and couldn't fall back, well, bad things happen, right?
- 26:05Yeah, it would be surprising if you were getting len, the len function from the built-ins over and over and over.
- 26:10And then you, for some reason, define len as a global.
- 26:14Python, you know, the language specification says it's going to start loading the global now,
- 26:18regardless of, you know, where it made it be able to pull.
- 26:21And that's the same for, you know, like attribute accesses.
- 26:24If you used to be getting an attribute off the class and then you shadow it on the instance,
- 26:28you need to start getting it from the instance now.
- 26:30You can't keep getting it from the class.
- 26:31Is it correct?
- 26:32Right.
- 26:32And this is one of those problems that arises from this being a static dynamic language that can be changed as the code runs.
- 26:39Because if this was compiled, wherever those things came from and what they were, they can't change.
- 26:44Their type was set.
- 26:45Their location was set.
- 26:47And so then the compiler can say, well, it's better if we inline this.
- 26:51Or it's better if we do this machine operation that works on integers better or some special thing like that.
- 26:59Right.
- 26:59It doesn't have to worry about it falling back.
- 27:01And I feel like that ability to adapt and change and just be super dynamic is what's kind of held it back a lot.
- 27:07Right.
- 27:07Yep.
- 27:08And I like that word they used, adapt, because that's kind of a big part of how the new interpreter works.
- 27:12You can change your code and the interpreter adapts with it.
- 27:15If X starts being an attribute on the instance rather than from the class, well, soon the interpreter will learn that sometime later after running your program.
- 27:24And then, OK, start doing the fast path for instance access rather than class access.
- 27:29Let's start there.
- 27:30How does it know?
- 27:31Right.
- 27:31It doesn't compile.
- 27:32So it has to figure this stuff out.
- 27:36Right.
- 27:36I run my code.
- 27:37Why does it know that I can now treat these things X and Y's integers versus strings?
- 27:42Yeah.
- 27:42So stepping back a little bit, like how does this new interpreter work?
- 27:46So the big change, kind of the headline is that the bytecode instructions can change themselves while they're running.
- 27:54Something that used to be a generic ad operation can become something that is specialized, which is kind of the specialized instruction is the terminology we use for adding two integers or adding two floats.
- 28:07And so this happens sort of in a couple of different phases.
- 28:10After you've run your code for some amount of time, basically after we've determined it's worth optimizing because optimization is free.
- 28:18So if something's only run once, you know, it's module level code or a class body.
- 28:22There's no, no reason to optimize that at all for like leader runs.
- 28:26Yeah.
- 28:26Yeah.
- 28:27We have heuristics for, okay, this, this code is warm.
- 28:30And that's, you know, a term that you hear in JITs often because it's a higher order for specializing.
- 28:35Basically after we've determined that a block of code is warm, we quicken it, which is that term that you used earlier.
- 28:43And this basically means walking over the bytecode instructions and replacing many of them with what we call adaptive variant.
- 28:51And, you know, you can, you can see an example in the pet, but you have to kind of walk through that example.
- 28:55If you have an attribute load, once the code is quickened after we've determined it's warm, we walk over all the instructions.
- 29:01All of the load attributes by code instructions become load adder adaptive.
- 29:06And what those adaptive instructions do is when we hit them, when we're actually doing the attribute load, in addition to actually loading the attribute, they will kind of do some fact finding.
- 29:18They'll gather some information and say, okay, I loaded the attribute, did it come from the class, did it come from the instance, did it come from the plot, did it come from a dict, did it come from a module?
- 29:26You know, there's, there's a bunch of different possibilities.
- 29:28Oh.
- 29:29And so using that information, the adaptive instruction can turn itself into one of the specialized instructions.
- 29:36So the example you have here on the screen can either be load adder instance value or module or slot.
- 29:41And what the specialized instructions do is really cool.
- 29:44Basically, they start with a couple of checks just to make sure if the assumptions are holding true.
- 29:49So for a load adder instance value, we, you know, check and make sure that, for example, the class of the object is as we expect.
- 29:58Then our attribute isn't shadowed by a descriptor or something weird like that, or that we're not now getting it off of a class object or whatever.
- 30:06And then it has a very optimized form of getting the actual attribute.
- 30:11There's a lot of expensive work that you can skip if you know that, you know, you have an attribute that is coming directly off the instance.
- 30:19Or another one is load adder slot.
- 30:22Slots are really interesting for Python performance.
- 30:25And, you know, they kind of capture more than a lot of the stuff, the difference of the possible and the common.
- 30:31And by that, I mean, it's possible that every time you access a field off of a class, that it was dynamically added and it came from somewhere else and it's totally new and it could be any type.
- 30:41What's more likely, though, is it's, you know, the customer always has a name and the name is always a string.
- 30:46Right.
- 30:47And with slots, you can sort of say, I don't want this particular class to be dynamic.
- 30:52And because of that, you can say, well, it doesn't need to have a dictionary that can evolve dynamically, which improves the access speed and the storage and all of that.
- 31:01And here you all are pointing out that, well, we could actually have a special opcode that knows whenever I access X, X is a slot thing.
- 31:09Skip all the other checks you might have to do before you get there.
- 31:12Well, yeah.
- 31:13And even accessing the slot is going to be faster.
- 31:16So I'm not 100% brushed up on how load adder slot works, but the slots are implemented using descriptors.
- 31:23So to get the slot from your class, you still, or from your instance, you still need to go to the class, look up the attribute in the class dict, find the descriptor, verify it's a descriptor, call the descriptor.
- 31:35Into that list.
- 31:36Yeah.
- 31:36Exactly.
- 31:37We can do it even faster than that.
- 31:39So even if you do have slots, this happens really fast without even any dictionary lookups.
- 31:44We say, has the class changed?
- 31:46No.
- 31:46Okay, cool.
- 31:47We'll get to this later, but we remember what offset the slot was at last time and we just reach directly to the object.
- 31:55Grab it.
- 31:55There's no dictionary lookups.
- 31:57We're not calling any descriptors, doing anything like that.
- 32:00It's about as close to, you know, a compiled language as a dynamic language would be.
- 32:04Yeah.
- 32:05Just verify it.
- 32:06Class has a change.
- 32:06Okay, reach in.
- 32:07I remember where it was.
- 32:08You know, I tried to kind of align this up saying the possible and the common.
- 32:11Most likely your code is not changing.
- 32:14And when it's well written, it's probably using the same type.
- 32:17You know, it's not like, well, sometimes it's a string and sometimes like that is the quote seven.
- 32:22And sometimes it's the actual integer seven.
- 32:24Like it should probably always be one.
- 32:26You just don't express that in code unless you're using type hints, right?
- 32:30And they're not enforced.
- 32:31Yeah.
- 32:31Yeah.
- 32:32And getting back to the adaptive nature and making sure that we are correct.
- 32:36You know, if we had something that was a slotted instance coming through a bunch of times and that suddenly you throw a module in or something with an instance dictionary or something else,
- 32:45or maybe the attribute doesn't exist or those quick checks that I mentioned that happen before we actually do the fast implementation of loading a slot.
- 32:55If any of those checks fail, then we basically fall back on the generic implementation.
- 33:00We say, oh, our assumptions don't hold.
- 33:03Go back.
- 33:03And if that happens enough time, then we go back to the adaptive form and the whole cycle.
- 33:07So if I'm throwing a bunch of integers into an add instruction and then later I stop and I start throwing a bunch of strings into an add instruction,
- 33:15we'll do the generic version of add for a little bit while we're kind of switching over.
- 33:19But then the interpreter will kind of get the hint and start, you know, specializing for string edition later.
- 33:25And it's really cool to see that happen.
- 33:28This portion of Talk Python To Me is brought to you by the Compiler Podcast from Red Hat.
- 33:32Just like you, I'm a big fan of podcasts.
- 33:35And I'm happy to share a new one from a highly respected and open source company.
- 33:40Compiler, an original podcast from Red Hat.
- 33:43With more and more of us working from home, it's important to keep our human connection with technology.
- 33:48With Compiler, you'll do just that.
- 33:50The Compiler Podcast unravels industry topics, trends, and things you've always wanted to know about tech through interviews with people who know it best.
- 33:58These conversations include answering big questions like, what is technical debt?
- 34:01What are hiring managers actually looking for?
- 34:04And do you have to know how to code to get started in open source?
- 34:07I was a guest on Red Hat's previous podcast, Command Line Heroes,
- 34:11and Compiler follows along in that excellent and polished style we came to expect from that show.
- 34:16I just listened to episode 12 of Compiler, How Should We Handle Failure?
- 34:20I really valued their conversation about making space for developers to fail
- 34:24so that they can learn and grow without fear of making mistakes or taking down the production website.
- 34:29It's a conversation we can all relate to, I'm sure.
- 34:32Listen to an episode of Compiler by visiting talkpython.fm/compiler.
- 34:36The link is in your podcast player's show notes.
- 34:38You can listen to Compiler on Apple Podcasts, Overcast, Spotify, Pocket Cast, or anywhere you listen to your podcasts.
- 34:44And yes, of course, you could subscribe by just searching for it in your podcast player,
- 34:49but do so by following talkpython.fm/compiler so that they know that you came from Talk Python To Me.
- 34:55My thanks to the Compiler Podcast for keeping this podcast going strong.
- 35:01Right, so we shouldn't, we being Python developers that write code that just executes without thinking too very much about what that means,
- 35:09we should not have to worry or maybe even know that this is happening, right?
- 35:14If everything goes as it's supposed to, it should be completely transparent to us.
- 35:18Yes.
- 35:19The only way that you should know that anything is different about 3.11 is your CPU cycles.
- 35:25The cloud hosting bill is the end of the month.
- 35:28You should be able to upgrade and if behavior changes, that's a buck.
- 35:32Tell us about that.
- 35:33Going from this adaptive version, the adaptive instance sounds slightly more expensive than the,
- 35:39just the old school load adder, for example,
- 35:42because it has to keep track and it does a little bit of inspecting to see what's going on.
- 35:46But then the new ones, once it gets adapted and quickened, it should be much faster.
- 35:50Is there a chance that it gets into some like weird loop where just about the time the adaptive one has decided to specialize it,
- 35:58it hits a case where it falls back and it like it ends up being slower rather than faster before?
- 36:03Well, yeah, the worst case scenario would be, you know, you send the same type through n number of times
- 36:10and then right when it's going to try to specialize you, set it through a different type.
- 36:13Exactly.
- 36:14Whatever, if n is the limit, like if it goes to n plus one times and then trips it back.
- 36:18Yeah.
- 36:19Yeah.
- 36:19Yeah.
- 36:20So that would be sort of the worst case scenario.
- 36:22But we have kind of ways of trying to avoid that if at all possible.
- 36:26Okay.
- 36:27So, for example, if we fail one of those checks, we don't immediately turn into the adaptive form.
- 36:33We will do it after, you know, that check has failed a certain number of times.
- 36:38And as just a concrete example, that number of times that we have hard coded is a prime number.
- 36:43So it's less likely that you'll fall into these sort of patterns where it's like, oh, I send three ins through that string.
- 36:49Three ins.
- 36:50It'd be hard to, you know, get that worst case behavior without being intentionally malicious.
- 36:54By the way, we got to keep in mind, like these are extremely small steps in our code, right?
- 37:01We might have multiple ones of these happening on a single line of what looks like, oh, there's one line of code.
- 37:07Like, well, there's five or however many instructions, bytecode instructions happening.
- 37:12And some of them may be specialized and some of them not, right?
- 37:15Yeah, exactly.
- 37:16And so the overall effect definitely smooths out where, sure, you may have a worst case behavior at one or two or three individual bytecode instructions.
- 37:24But your typical function is going to have much more than that, even a smallish function is going to have, you know, 20 or 30 instructions doing it, you know, real.
- 37:32Yeah.
- 37:32Yeah.
- 37:33If you care about its performance, it'll be doing a lot there.
- 37:35Exactly.
- 37:36And so some will specialize successfully, some won't.
- 37:38But in general, your code will get 25-ish percent faster.
- 37:42Is there a way you could know?
- 37:44I mean, is there a way that you might be able to know if it specializes or not?
- 37:46We'll get to that.
- 37:47But it looks like if I go and use the disk module, D-I-S, not for disrespect, but for disassembly.
- 37:57Disassembly, yeah.
- 37:57So you can say, you know, import disk and then maybe from disk, import disk.
- 38:02You can say disk and give it a function or something.
- 38:04It'll write out the bytecode of what's happening.
- 38:07Does all of this mean that if I do this in 3.11, I might see additional bytecodes than before?
- 38:14You know, instead of load adder, would I maybe see the load adder instance value?
- 38:17Will I actually be able to observe these specializations?
- 38:20If you pass a keyword argument to your disk utilities, then yes, you will be able to see.
- 38:26Okay.
- 38:26But if I don't, for compatibility reasons like load adder adaptive and load adder instance,
- 38:32those are just going to return as load adder?
- 38:34Load adder.
- 38:35Exactly.
- 38:35Okay.
- 38:36Yeah.
- 38:36So the idea is anyone that's currently consuming the bytecode,
- 38:39they shouldn't have to worry about specialization because the idea is they're totally transparent.
- 38:43You know, so they should only see what the original bytecode was.
- 38:47But if you want to get at it, then yeah, if you get any of the disk utilities,
- 38:51you could pass it adaptive through and that will show you the adaptive.
- 38:56And again, you'll only see them if it's actually gets quick at meaning if you run it,
- 39:00you know, a dozen times or something.
- 39:02Okay.
- 39:02So if I wrote, say a function and so often what you're doing,
- 39:06if you're playing with disk is like you write the function and then you immediately write,
- 39:10print out the disk output.
- 39:12Maybe you've never called it.
- 39:13Right.
- 39:14And so that might actually give you a different,
- 39:16even if you said yes to the specialization output,
- 39:19that still might not give you anything interesting.
- 39:22It won't give you it.
- 39:23Yeah.
- 39:23It'll just give you as if you hadn't passed the keyboard argument.
- 39:25Because again, this all happens at runtime.
- 39:27So if the code isn't being run, nothing happens.
- 39:29You know, we don't specialize code that is ever run.
- 39:33What counts as warm, Mike?
- 39:35How many times do I got to call it?
- 39:36The official answer is that's an implementation detail of the interpreter subject to change at any time.
- 39:41The actual answer is either eight calls or eight times through a loop in a function.
- 39:46So if your function has a loop that executes more than eight times,
- 39:50or if you call it more than eight times.
- 39:52So just calling your function eight times should be enough to quicken it.
- 39:55Right.
- 39:56Well, maybe that number changes in the future, but just having a sense, like, is it 10 or is it 10,000?
- 40:02You know what I mean?
- 40:03Like, where's the scale up before I see something?
- 40:07Yeah, if you want to make sure it's quickened, but you don't want to take up too much time,
- 40:09I'd say just run it a couple less at a time.
- 40:11As short man, when we're writing tests and stuff, we do like 100 or 1,000.
- 40:15Because that also gives it time to actually adapt to the actual data that you're sending.
- 40:19Because it's not enough to just quicken it, then you'll just have a bunch of adaptive instruction.
- 40:23They actually have to see something.
- 40:24Yeah, well, now we're paying attention.
- 40:25Like, great.
- 40:26You need to have something to pay attention to, right?
- 40:29Yeah, and you'll see that too.
- 40:30Because if you have any sort of logic flow inside of your function,
- 40:34when you're looking at the bytecode, any paths that are hit will be specialized,
- 40:38but any paths that aren't obviously won't because we don't specialize dead code.
- 40:42So it has a bit of a code coverage aspect, right?
- 40:46You can think about it like that.
- 40:47If you look at it, you might see part of your code and it's just,
- 40:50it's unmodified because whatever you're doing to it didn't hit this else case ever.
- 40:55Yeah, well, and that's what's really exciting about this too,
- 40:58is when you're, if you run your code a bunch of times and then you call this on it,
- 41:03you see a lot of information that would potentially be useful if you were,
- 41:07for example, JIT compiling that function.
- 41:09You see at every addition site, you're adding floats or ints.
- 41:14You see at every attribute load site, whether it's a slot or not,
- 41:17you see where the dent code is, you see where the hot code.
- 41:19All that stuff is sort of getting back to what I said,
- 41:22how this sort of enables us to build upon in the future.
- 41:25Not only can we add more specializations or specialize more op codes or,
- 41:29you know, do that more efficiently, we can also use that information to kind of infer additional
- 41:35properties about the code that are useful for, you know, other faster, lower representation.
- 41:40Yeah, I can certainly see how that might be.
- 41:42Might inform some kind of JIT engine in the future.
- 41:45Yeah.
- 41:46I think the PEP is interesting.
- 41:48The PEP 659, people can check that out.
- 41:50But like you said, it's informational.
- 41:52So it's not really the implementation exactly.
- 41:54Yeah.
- 41:55So let's talk a bit about your project that you did.
- 41:59In addition to just being on the team, the personal project that you did,
- 42:03that basically takes all of these ideas we've been talking about and says, well, two things.
- 42:08One, can I take code and look at that and get that answer?
- 42:12Again, kind of back to my code coverage example, like coloring code lines to mean stuff.
- 42:16And then what's interesting about this, and we'll talk to this example that you put up,
- 42:20is there's actionable stuff you could do to make your code faster if you were in a super
- 42:25tight loop section.
- 42:26Like I feel like applying this visualization could help you allow Python to specialize more
- 42:32rather than less.
- 42:33Yeah.
- 42:34I mean, in general, this tool is really useful for us as maintainers of the specialization
- 42:40stuff because we get to see, you know, where we're failing to specialize.
- 42:44Because ideally, you know, if we've done our job well, you should get past your Python
- 42:48without changing your code at all.
- 42:49First and foremost, this is a tool for, you know, us in our work so that we can see, okay,
- 42:54what can we still work on here?
- 42:56But that is sort of a cool knockout effect is that if you do run on your code, you also
- 43:01know where it's not specializing.
- 43:02And if you know enough about how specialization works, you may be able to fix that.
- 43:06But I would say a word of caution against, you know, like getting two in the weeds and
- 43:12trying to get every single bytecode to do what you want, because that's, there are much
- 43:16better ways of making it faster, right?
- 43:18There are places where you're like, these two functions, I know we got 20,000 lines
- 43:22of Python, but these two, which are like 20 lines, they are so important.
- 43:27And they happen so frequently.
- 43:28Anything you can do to make them faster matters.
- 43:31You know, people rewrite that kind of stuff in Rust or in Cython.
- 43:34Before you go that far, maybe adding a dot zero on the end of a number is all it takes.
- 43:40You know, something like that, right?
- 43:41That's kind of what I'm getting at.
- 43:42Not to go crazy or try to think you should mess with the whole program.
- 43:45But there are these times where like five lines matter a lot.
- 43:49Yeah.
- 43:50Okay.
- 43:50Well, tell us about your project specialist.
- 43:53One really cool thing that our specializing adaptive interpreter does is we've worked really
- 43:59hard to basically make it easy for us to get information about how well specializations
- 44:03are working.
- 44:04So you can actually compile Python.
- 44:06It'll run a lot slower, but you can compile Python with this option with PyStats.
- 44:11And that basically dumps all of the specialization stats.
- 44:14Yeah.
- 44:15And you actually pointed out that you can, in the faster CPython idea section, it like lists
- 44:21out like a...
- 44:22Yeah.
- 44:22So there's tons of counters.
- 44:23So you can see that when we run our benchmarks, you know, load adder instance value is run
- 44:28what, 2 billion times, almost 3 billion times.
- 44:30And it misses its assumptions, 1% of those.
- 44:34And yeah.
- 44:35And so there's tons of these counters that you can dump.
- 44:37And that's really cool because we can run our performance benchmarks and see how those numbers
- 44:41have changed.
- 44:41And even cooler than that, it allows us kind of separately to, for example, there's been
- 44:47at least one case where we've worked with a large company that has a big private internal
- 44:51app and they can run it using Python 3.11 and we can get these stats without actually looking
- 44:56at the source code, which is really cool.
- 44:57And so we want to help you be faster and we're working on the runtime, but we don't want you
- 45:03don't want to show us your code.
- 45:04And so we're not going to look at it.
- 45:05And so those stats are really useful for kind of knowing, okay, 90% of my attribute access
- 45:10were able to be specialized.
- 45:11What about the remaining 10%?
- 45:13Where are they?
- 45:14So, you know, an additional question, like why couldn't they be specialized?
- 45:17And that's something that's a lot easier to tell when you're looking at the code.
- 45:21And so this tool was basically my original intention for writing it is, you know, once we get beyond,
- 45:28you know, seeing the stats for benchmark and we run something on it, that makes it easy to
- 45:32tell at a glance where we're failing and how.
- 45:36Right.
- 45:36It's like saying you have 96% code coverage versus these two lines are the ones that are not
- 45:41getting covered.
- 45:42Exactly.
- 45:43You get a lot more information from actually getting those line numbers than from the 97%.
- 45:47And so basically the way it works, we already talked about how in the disk module, you can
- 45:54see which instructions are adaptive or specialized.
- 45:57And all that this tool does, it visualizes.
- 46:00Literally the implementation of this tool is just a for loop over this, where we just kind
- 46:08of categorize the different instructions and then map those to colors and all sorts of crazy
- 46:12concepts.
- 46:12Yeah.
- 46:12Yeah.
- 46:12And for people listening, you know, imagine some code and here you've got a for loop with
- 46:18the tuple decomposition.
- 46:20So you got for I comma T in enumerative text that are going to do some stuff.
- 46:24And it has the I and the T turned green, but then some dictionary access turned yellow.
- 46:30And it talks about, is it not at all specialized?
- 46:33Is it, did it try but fail to get specialized?
- 46:37And things like that, right?
- 46:38Yep.
- 46:38Yeah.
- 46:39So green indicates successful specializations.
- 46:42Red are those adaptive instructions that are slightly slower and represent missed specializations.
- 46:47Yellow and orange are kind of a gradient.
- 46:50As we talked about, you know, one line of Python code easily be 10 or 20 byte code instruction.
- 46:56Right.
- 46:56Yeah.
- 46:57Yeah.
- 46:57It's kind of a way of compressing that information.
- 46:59It's really.
- 47:00And one thing I want to point out about this too is, you know, you'll notice it's actually,
- 47:06you see characters within a line.
- 47:08And this is something that's really cool because this is piggybacking on a feature that's completely
- 47:12unrelated to specialization.
- 47:13Originally, when I was writing this, it highlighted each line.
- 47:18So you could see this line was kind of green or this line was kind of yellow.
- 47:21But then I remembered, maybe you're familiar, in Python 3.11, we have really, really formative
- 47:29tracebacks where it will actually underline the part of the code that has a syntax error that
- 47:34has an exception that was raised or something.
- 47:37And so that's the PEP that's linked first in the description there.
- 47:41It's, you know, called fine-grained error locate or fine-grained locations tracebacks.
- 47:46And so what that means is that previously we just had line number information in the bytecode,
- 47:51but now we have line number and end line number and start column and end column information,
- 47:56which means that due to this completely unrelated feature, we can now also map it directly to which
- 48:01characters in source file correspond to individual bytecode.
- 48:04That's super cool.
- 48:05Yeah.
- 48:05So for example, here we've got a string and you're accessing it by element, by passing an index,
- 48:12and you were able to highlight the square brackets as a separate classification on that array indexing
- 48:19or that string indexing.
- 48:20Exactly.
- 48:21So it wouldn't have been as helpful to just see that that line was kind of yellow-orange-ish.
- 48:25You know, we see that the fast variable store was really, really quick.
- 48:29We see that, you know, the modulo operation and the indexing of string by int wasn't that fast.
- 48:37We weren't able to specialize it, but, you know, we were able to specialize, you know, the lookup of the name TILEN.
- 48:46We weren't able to specialize the function column.
- 48:47So that sort of information, that granularity is really, really cool.
- 48:51Yeah, it is super cool.
- 48:52And I think a good way to go through this, you know, you've got some more background that you write about here,
- 48:56but we've already talked a lot about specializing.
- 48:58Yeah, this is just summarizing the pet piece.
- 48:59Yeah, exactly.
- 49:00People can check it out there if they want the TILEN, the too-long-didn't-read version.
- 49:04But you've got this really nice example of, you know, what may be in the first few weeks of some kind of Python programming class.
- 49:11Write a program that converts Fahrenheit to Celsius and Celsius to Fahrenheit,
- 49:16and then just tests that, you know, round-tripping numbers gives you basically the same answer back within floating-point variations, right?
- 49:24Yeah, I really like this example because it, you know, as we'll show, it's kind of presented through the lens of performance optimization,
- 49:31but it also does a good job of showing you kind of how the interpreter works and how those little tweaks kind of cascade.
- 49:37Mm-hmm, absolutely.
- 49:38And it highlights certain things you can take advantage of that, you know, if you just slightly change the order,
- 49:44it actually has a different runtime behavior, which we don't often think about in Python.
- 49:48We're doing C++.
- 49:49We would maybe debate, do you dereference that pointer first, or can you do it in the loop?
- 49:53Yeah.
- 49:54But not so much here.
- 49:56So let's go through, I mean, I guess just to remind people, Fahrenheit to Celsius, you would say X equals F minus 32,
- 50:03and then you multiply the result once you've shifted the zero by five divided by nine,
- 50:08and the reverse is you multiply the Celsius by nine divided by five, and then you add the 32 to shift the zero again.
- 50:15And basically that's all there is to it.
- 50:17And then you go through and say, well, let's run the specialist on it to get its output.
- 50:21And maybe talk about this first variation that we get here.
- 50:24Yeah.
- 50:24So as we were talking about, you know, the red indicates is adaptive instructions, and the green indicates the specialized instruction.
- 50:32So we can see here that some things were specialized very well.
- 50:35For instance, look at a cert roundtrip.
- 50:37You know, that's great green.
- 50:38Because it's in that hot loop, we got enough information about it to say, okay, a cert roundtrip is being loaded from the global namespace.
- 50:47And it's a Python function.
- 50:48So we can do that cool Python to Python call optimization.
- 50:53And, you know, that's basically as fast as any function call in Python is going to be.
- 50:58But some things aren't specialized.
- 51:01So the things that jump out, you know, the things that we may want to actually take a closer look at would be the map, which is, you know, yellow and red.
- 51:08So, for instance, we can, the loads of the local variable f in that first function and the load of the constant 32, those are yellow because the map that they're involved in, the subtraction operation, wasn't specialized.
- 51:23But the individual loads of those instructions were specialized.
- 51:26I see.
- 51:26So half yes, half no for what they were involved in.
- 51:29Yeah, yeah.
- 51:29Green plus red equals yellow.
- 51:31So, yeah.
- 51:33So that subtraction wasn't specialized.
- 51:35And the reason is, is in 3.11, just based on heuristics that we gathered, we determined it was worth it, at least for the time being, to optimize int plus int, float plus float, but not int plus float, float plus int.
- 51:48And so what we're doing here is we're subtracting a float and an int.
- 51:52And so we're able to see that that isn't specializable.
- 51:55But if we were to somehow change that so that it was two floats, two ints, then it would be specializable.
- 52:01Right.
- 52:01Because when I look at it, it looks like it absolutely should have been specialized.
- 52:04I have a float minus an int.
- 52:07The int is even a constant.
- 52:08Like you're, okay, well, this is standard math.
- 52:13And it's always a float and it's always an int and it's always subtraction.
- 52:16Right.
- 52:16It seems like that should just, well, the math should be obvious and fast.
- 52:20But because, as you pointed out, there's this peculiarity or maybe an implementation detail for the moment.
- 52:26Absolutely an implementation detail.
- 52:27Yeah, yeah, yeah.
- 52:28Yeah.
- 52:28If it's an int and a float, well, right now that problem is not solved.
- 52:33Maybe it will be in the future, right?
- 52:34It seems like pretty low hanging fruit, but you've got all the variations, right?
- 52:37Yeah.
- 52:38Specializations aren't free.
- 52:39So for instance, like when we're running those adaptive instructions, we need to check for all of the different possible specializations.
- 52:46So every time we add a new specialization that has some cost.
- 52:50And basically we determined, at least for the time being, like I said, that we've tried to do int plus float and float plus int.
- 52:57At least based on the benchmarks that we have and the code that we've seen, it just isn't worth it.
- 53:02Sure.
- 53:02Okay.
- 53:03Yeah.
- 53:03Yeah.
- 53:04And it's something like int plus int is very easy to do quickly.
- 53:08Float plus float is very easy to do quickly.
- 53:10Int plus float, there's some coercion that needs to happen there.
- 53:13Right.
- 53:14So it's already constant anyway.
- 53:15Yeah.
- 53:16Yeah.
- 53:16So it's not something that, it's something that caught some time to check, but we don't have a significantly faster wave.
- 53:23It doesn't happen on a register on the CPU or something.
- 53:26Yeah, exactly.
- 53:27Okay.
- 53:28So then you say, well, look what the problem is.
- 53:31It's float in int where we have f minus 32, which seems again, completely straightforward.
- 53:36What if they're both floats?
- 53:38Well, what if like, you know, it's going to end up a float in the end anyway.
- 53:41How about make it 32.0 instead of 32?
- 53:44Yep.
- 53:44And then bam, that whole line turns green, right?
- 53:47Yep.
- 53:47Yeah.
- 53:47So now you're basically doing that entire line using fast local variables and look like native floating point operation.
- 53:55You're just adding literally two C doubles together, which is.
- 53:59Yeah.
- 53:59And this is what I was talking about where you could look at that line and go, oh, well, I just wrote the integer 32, but I'm doing floating point math.
- 54:07It's not like I'm doing integer math.
- 54:08So if you just put, you know, write it as a constant with a zero, you know, dot zero on it, that's a pretty low effort change.
- 54:15And here you go.
- 54:16Python can help you more and go faster, right?
- 54:18Yeah.
- 54:19And that's not a transformation that we can do for you.
- 54:21Because if F is an instance of some user class that defines dunder, so that would be a visible change if it started receiving a float as a right hand argument.
- 54:30So those are things that we can't do while making the language still.
- 54:34Right.
- 54:35But your specialist tool can show you.
- 54:38And again, figure out where your code is slow and then consider whether they're just like, well, we only got 100,000 lines.
- 54:44Let's who's assigned to specializing today.
- 54:47Yeah.
- 54:47And it also requires, this is a simpler example, but it does require, you know, a somewhat deep knowledge of how the specialization work.
- 54:55Because for things other than binary operation, it's not going to become clear what the fix is.
- 55:01You just see kind of where the, I hesitate to even call it a problem, but you see where there's the potential for improvement, but not necessarily how to improve.
- 55:08Yeah.
- 55:08And then you have another one in here that's, I think, really interesting because it, so often when we're talking about math and at least commutative operations, it doesn't matter which order you do them in.
- 55:19Like five times seven times three.
- 55:21If it's the first two and then the result or multiply the last two.
- 55:25And, you know, unless there's some weird floating point edge case that, you know, the IEEE representation goes haywire.
- 55:31It doesn't matter.
- 55:31Right.
- 55:32And so, for example, here you've got, you know, to finish off the Fahrenheit to Celsius conversion, it's the X times five divided by nine.
- 55:40And that one is busted too for the same reason, right?
- 55:43Because it's a five.
- 55:43Yeah.
- 55:44Because, so this is kind of for two reasons.
- 55:47This line isn't as good as it could be under ideal conditions.
- 55:50So, you know, X is a floating point number, five is an integer.
- 55:54So we have the same problem.
- 55:55We specialize multiplication for int and int and float flows, but not for int and float.
- 56:00And the division is a different problem.
- 56:03We don't try to specialize division at all for the reason that it's kind of problematic because the right hand side could be zero.
- 56:08And then you have to check for that and all sorts of things that you need to check for that make it not as much of a payoff.
- 56:14So, you know, we have both an operation that we can't specialize, but it isn't being specialized.
- 56:21And then another one that we're not even trying to specialize at all.
- 56:24But then back to the commutative thing, you're like, well, what if we did the division, right?
- 56:29What if we did the division, like, parenthesis five divided by nine?
- 56:33And then X times that, right?
- 56:35Yep.
- 56:35And so wading through more of these implementation details, Python's compiler, you know, we have a bytecode compiler.
- 56:42It's not a compiling to machine code, but it can perform simple optimization.
- 56:46So by changing the order of operations, the bytecode compiler sees, oh, five divided by nine.
- 56:52I can do that at compile time once rather than at runtime literally every time.
- 56:57That's never going to change.
- 56:58And so by changing that order of a problem.
- 57:00Yeah.
- 57:01Sorry.
- 57:01Regardless of specialization, that's better anyway.
- 57:04Right.
- 57:04Because that happens when the PYC file is generated or when the equivalent thing in memory is generated.
- 57:09And then it's just known as a constant, right?
- 57:13Yeah.
- 57:13And you're doing no division of runtime anymore.
- 57:15So you turn this from two operations, one of which is pretty expensive, to just one operation.
- 57:20All you're doing is a multiply by a constant.
- 57:22Oh.
- 57:23Yep.
- 57:23And so you can see that, you know, once we apply that transformation to our code, everything's all break green.
- 57:29This is as specialized as it is.
- 57:32Right.
- 57:32Because in Python 3, five divided by nine is a floating point, right?
- 57:36Yes.
- 57:36Doesn't module it out or whatever.
- 57:38Yeah.
- 57:39So then it becomes float times float, which then can be specialized.
- 57:43And that first division part is something that is done at runtime when it first runs, but only once, which is fantastic.
- 57:50Like parse time, basically.
- 57:51Yeah.
- 57:52So, yeah, this function or these functions, this code is much better as a result of just understanding.
- 57:58Yeah.
- 57:58And this transformation isn't something that Python can do for you because it changes the semantics of the language.
- 58:03Again, if X is some user object, then it can serve the types that are being passed to it.
- 58:07Yeah.
- 58:08If it implements multiply, it expected to receive the five.
- 58:11It didn't expect to receive 1.2715 or whatever the heck that is, right?
- 58:16Yep.
- 58:17Yeah.
- 58:17Cool.
- 58:17All right.
- 58:18Well, this is a really cool tool.
- 58:19I definitely encourage people if they're listening, just, you know, come over and just there's pictures of code and color.
- 58:26Just scroll quickly through it to see what we're talking about.
- 58:29And I find it super valuable because it highlights with color right on the code that you wrote.
- 58:34It doesn't spit out the byte code and say, here's the byte code improvements, but it highlights your code and says the code you wrote is being improved by Python or not being improved by Python here.
- 58:45Right.
- 58:45And just understanding that it might not matter.
- 58:47And it might matter a lot to you.
- 58:49It depends.
- 58:49Yeah.
- 58:49And another thing to highlight, too, that's kind of different about this tool from maybe most tools that you would use is, you know, this isn't this isn't static analysis.
- 58:58It's not like mypy or pilot where it's running over your code just in its file.
- 59:02You actually need to run your code under this tool for it to be able to do it.
- 59:06Because, again, all this happens at runtime.
- 59:08So it's only after running the code that specialists walk over and see where you're running the code out.
- 59:14Enough, right?
- 59:15Yes.
- 59:15Yeah.
- 59:16So, for example, if I just had this function and I didn't actually call test convergence at the bottom there, the dunder name equals paint, everything would just be white because nothing actually ran.
- 59:26Right.
- 59:27Right.
- 59:27So in this example here, you've got, let's see, two, four, six, eight, nine.
- 59:32Surprising that number.
- 59:33You have nine test values that you're passing in and you're looping over all those values and testing it.
- 59:38You need to, if you're going to apply this to your code, it's super important that you come up with a scenario of representative data.
- 59:44And for now, n greater than eight.
- 59:46Who knows?
- 59:47Or something that's loopy.
- 59:50It's, you know, it runs loops eight times or something.
- 59:53Basically, if the same bytecode instructions are being executed a bunch of times, that's how we tell that it's hot.
- 59:58Whether that's in a loop or for repeated calls.
- 1:00:00I can see it's pretty easy to forget that.
- 1:00:03And people might run it and go, it didn't do anything.
- 1:00:05It did nothing.
- 1:00:05It's just all white.
- 1:00:06Yeah.
- 1:00:07Yeah.
- 1:00:07Maybe you should add, I mean, I'm not, I'm not trying to issue a, an audio PR or anything, but maybe it should have some kind of warning.
- 1:00:14Like if there's zero color at all, like a warning, like, are you sure you ran it?
- 1:00:19Because we don't think you did anything.
- 1:00:20I actually really liked that request.
- 1:00:22Do that.
- 1:00:22Yeah.
- 1:00:24Cause you would know, right?
- 1:00:25Like, you'd know if like I've colored nothing in any color whatsoever.
- 1:00:28Yeah.
- 1:00:29And I look at him like, oh, I did something wrong.
- 1:00:31But someone else is going to be like, Fran did something wrong.
- 1:00:33Yes, exactly.
- 1:00:34Got to protect, got to protect my reputation.
- 1:00:36Well, and just like limit the issues being raised.
- 1:00:40Like how many times you want to say, did you remember to call, call it enough times?
- 1:00:44Yeah.
- 1:00:45Yeah.
- 1:00:46Cool.
- 1:00:46I definitely think people should check this out if they're interested in seeing how the adaptive specializing, specializing adaptive interpreter from Python 3.11 is applied to their code.
- 1:00:56I guess also other caveat, like really not super handy.
- 1:00:59If you try to do this with 3.10, you got to have 3.11.
- 1:01:01It refuses to run under 3.10.
- 1:01:03Yeah.
- 1:01:04Cause I accidentally made that mistake enough times where I just had the Python environment I had acted with 3.10.
- 1:01:10I'm like, not working.
- 1:01:11Darn.
- 1:01:11Yeah.
- 1:01:12It's all like again.
- 1:01:13It doesn't exist.
- 1:01:14Yeah.
- 1:01:14All that stuff.
- 1:01:15Yeah.
- 1:01:15Yeah.
- 1:01:16Yeah.
- 1:01:16So, so yeah, no, you need to be running at 3.12, but, or sorry, 3.11 or 4.3.12.
- 1:01:22But, you know, as you showed earlier, you can download it from Python.org.
- 1:01:26My favorite way of installing Python versions, PyN, has had 3.11 dev for a while now.
- 1:01:34They also have 3.12 dev for crazy and you want to try it out.
- 1:01:37But, but yeah, you do need, you do need a 3.11.
- 1:01:40Fantastic.
- 1:01:41Well, really great work.
- 1:01:42I think it's quite a contribution.
- 1:01:44It really highlights all the work that's being done in 3.11.
- 1:01:46So well done.
- 1:01:47All right.
- 1:01:48Now, before you get out of here, I got to ask you the final two questions.
- 1:01:51If you're going to write some Python code, if you're going to work on specialist, what
- 1:01:55editor do you use?
- 1:01:56I use VS Code.
- 1:01:57Okay.
- 1:01:57Right on.
- 1:01:58And then notable PyPI package, something you came across, like, oh, this thing is cool.
- 1:02:02Maybe not the most popular, but something that you want to give a shot at.
- 1:02:05Yeah.
- 1:02:06I thought about this.
- 1:02:06Can I say two?
- 1:02:08Is it only limited?
- 1:02:09Two is fine.
- 1:02:09Okay.
- 1:02:09Cool.
- 1:02:10So there's two.
- 1:02:11I really like creative packages that kind of blur the line between like, what is Python
- 1:02:15and what isn't.
- 1:02:16Okay.
- 1:02:17So the first one is called PyMetal 3, PyMTL 3.
- 1:02:20This is so cool.
- 1:02:21It allows you to design hardware using Python.
- 1:02:23Interesting.
- 1:02:24Okay.
- 1:02:25And you can basically design everything from just a small, you know, set of logic gates
- 1:02:30to a full chip, then export it to Verilog.
- 1:02:33You run it on an FPGA.
- 1:02:34And, you know, this is kind of my hardware background coming through.
- 1:02:37Right, right, right.
- 1:02:39Yeah.
- 1:02:39My brother is actually studying at Cal Poly San Luis Obispo right now.
- 1:02:43And he is on a research team that's designing an entire processor in Python.
- 1:02:48And so basically the processor itself is designed in Python and you can test it with Python.
- 1:02:53So they're testing with hypothesis.
- 1:02:55And it's a really cool, creative way of kind of doing this sort of stuff.
- 1:03:01Yeah.
- 1:03:01You don't need any special hardware to make it happen either, right?
- 1:03:04Yeah, exactly.
- 1:03:05You can just run it on your local machine and now you've got a RISC-V chip running.
- 1:03:09Nice.
- 1:03:10Yeah.
- 1:03:10So the other one is another kind of cool, weird, low-level hardware package.
- 1:03:16I don't know if I count this pip installable.
- 1:03:17It's called PeachPy.
- 1:03:18I don't know how well maintained it is, but you have to do that thing where you tell pip
- 1:03:23to install from like a GitHub link.
- 1:03:25All right.
- 1:03:26Well, you can pip install from a GitHub link.
- 1:03:28Yeah, yeah, yeah.
- 1:03:29You got to give it a really weird URL instead of just the name.
- 1:03:32Yeah, yeah.
- 1:03:32Okay.
- 1:03:33Got it.
- 1:03:33Sure.
- 1:03:33And so this is super cool.
- 1:03:35It's an x86-64 assembler in Python.
- 1:03:39Okay.
- 1:03:39So with this, you can basically implement a compiler or if you like it, a just-in-time
- 1:03:46compiler for basically x86 hardware.
- 1:03:49So what this allows you to do is in your Python code, it takes care of doing things like allocating
- 1:03:55hardware registers and labeling jumps and all that sort of stuff, calling conventions.
- 1:04:01And so you can specify exactly what assembly instructions you want to execute, assemble them,
- 1:04:06and then it will package them up in a Python function object and you can call your assembly
- 1:04:11code from Python, which I think is so cool.
- 1:04:13Wow.
- 1:04:13And it actually executes as assembly instructions?
- 1:04:16Yes.
- 1:04:17Yeah.
- 1:04:17So it's like faults and everything.
- 1:04:19Yeah.
- 1:04:20Yeah, of course.
- 1:04:20It's the most common thing it does.
- 1:04:22Yeah.
- 1:04:22But I mean, like a simple example, you can pass in a Pyaltic pointer and then add, you know,
- 1:04:28eight or 16 or whatever to get the type of it and then return that and it will return.
- 1:04:32Yeah.
- 1:04:33Very cool.
- 1:04:33So you can see the code example on here for PeachBuy.
- 1:04:37I'll put the link in the show notes.
- 1:04:38But you do things like create an argument and then you create a general purpose register
- 1:04:43and you load the argument onto the register and you might call the ISA SSE4 operation or
- 1:04:49whatever.
- 1:04:49Pretty cool.
- 1:04:49Yeah.
- 1:04:50Two really good ones.
- 1:04:51All right.
- 1:04:51Final call to action.
- 1:04:52People are interested in specialist and exploring the specializing adaptive interpreter.
- 1:04:57What do you tell them?
- 1:04:58I think the most important thing you can do is download or if you're feeling like it,
- 1:05:02build Python 3.11 and try running it for yourself.
- 1:05:05See if your code gets faster.
- 1:05:06It probably will.
- 1:05:08If it doesn't, then specialists could help show you where it's not.
- 1:05:12And if that is surprising to you, then you could report it to us.
- 1:05:16You know, if like, oh, my code got slower for some reason, you know, and it looks like
- 1:05:22this specific pattern, what's causing it.
- 1:05:24That's something that we care about.
- 1:05:25Yeah, I suspect this interpreter is something that's never done.
- 1:05:28It's clear you could always add more cases.
- 1:05:31You could make it decide sooner or easier or more accurately when and how to specialize and
- 1:05:37add more by.
- 1:05:38There's like a lot of stuff you could do, right?
- 1:05:40As opposed to, well, yeah, now you read CSV files.
- 1:05:42That part is done.
- 1:05:44Yeah.
- 1:05:44And again, if you're feeling up to it and you've got a huge pure Python app, you can
- 1:05:48even compile with stats and dump that out and take a peek at it.
- 1:05:52I think you showed our repository earlier where we have our issue tracker, where we kind
- 1:05:56of just spitball ideas and keep track of work in progress.
- 1:05:59Yeah, this one.
- 1:05:59If you go to the issue tracker here.
- 1:06:01Sorry, I was wrong.
- 1:06:02And the ideas one.
- 1:06:03Yeah.
- 1:06:03So you've got it's faster dash CPython slash ideas on GitHub.
- 1:06:07Yeah.
- 1:06:07So if you go to issues there, that's all our work in progress.
- 1:06:10And if you have experience optimizing dynamic languages or if you see a cool research paper
- 1:06:15something that you want us to know about opening issue here and where things get done.
- 1:06:20Yeah.
- 1:06:21Fantastic.
- 1:06:21Well, thank you for making Python faster.
- 1:06:24I think it's really, really important.
- 1:06:26I mean, I'm always a little bit conflicted because I have some pretty complicated web apps
- 1:06:31that get a decent amount of traffic and they've been fine, like really, really fine.
- 1:06:35You know, handful of milliseconds response time.
- 1:06:37I mean, they're doing all sorts of madness with databases and HTML and all kinds of stuff.
- 1:06:42So on one hand, I don't know if I need Python to be faster, but on the other, people are
- 1:06:46deciding which language they're going to choose and where they can do their work.
- 1:06:50And sometimes either perceived or real reasons, people think Python is not fast enough.
- 1:06:56Right.
- 1:06:56And so this is important work that will really help some people and will help the community
- 1:07:01to be stronger.
- 1:07:01So thank you.
- 1:07:02We love Python program.
- 1:07:04Right on.
- 1:07:05Right on.
- 1:07:05Cool.
- 1:07:05Well, thank you so much for being here.
- 1:07:07It's great to chat with you.
- 1:07:08Thanks again for having me.
- 1:07:10Yeah, you bet.
- 1:07:10Bye.
- 1:07:10This has been another episode of Talk Python To Me.
- 1:07:14Thank you to our sponsors.
- 1:07:16Be sure to check out what they're offering.
- 1:07:17It really helps support the show.
- 1:07:19Starting a business is hard.
- 1:07:20Microsoft for Startups, Founders Hub provides all founders at any stage with free resources
- 1:07:26and connections to solve startup challenges.
- 1:07:29Apply for free today at talkpython.fm/foundershub.
- 1:07:33Listen to an episode of Compiler, an original podcast from Red Hat.
- 1:07:37Compiler unravels industry topics, trends, and things you've always wanted to know about
- 1:07:41tech through interviews with the people who know it best.
- 1:07:44Subscribe today by following talkpython.fm/compiler.
- 1:07:48Want to level up your Python?
- 1:07:50We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:07:53Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:07:58And best of all, there's not a subscription in sight.
- 1:08:01Check it out for yourself at training.talkpython.fm.
- 1:08:04Be sure to subscribe to the show.
- 1:08:05Open your favorite podcast app and search for Python.
- 1:08:08We should be right at the top.
- 1:08:09You can also find the iTunes feed at /itunes, the Google Play feed at /play,
- 1:08:14and the direct RSS feed at /rss on talkpython.fm.
- 1:08:18We're live streaming most of our recordings these days.
- 1:08:21If you want to be part of the show and have your comments featured on the air,
- 1:08:24be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:08:29This is your host, Michael Kennedy.
- 1:08:30Thanks so much for listening.
- 1:08:31I really appreciate it.
- 1:08:33Now get out there and write some Python code.
- 1:08:34I really appreciate it.