Michael Kennedy: Hello and welcome to Python Bytes, where we deliver news and headlines directly to your earbuds.
Michael Kennedy: This is episode 454, recorded October 20th, 2025. I'm Michael Kennedy.
Brian Okken: And I'm Brian Okken.
Michael Kennedy: And this episode is brought to you by us. We have increasingly more monotonically increasing
Michael Kennedy: number of ways in which you can support us and things that Brian and I both feel like
Michael Kennedy: contribute a lot of value, right? Your pytest book, your pytest courses,
Michael Kennedy: All the courses over at Talk Python,
Michael Kennedy: foreshadowing, some of that's coming later as well.
Michael Kennedy: The Patreon supporters,
Michael Kennedy: pretty much all of these things.
Michael Kennedy: We create them not just so that we have a job,
Michael Kennedy: but also because we think the world needs them.
Michael Kennedy: We appreciate when you all agree with that and support them.
Michael Kennedy: You want to connect with us, connect on social media
Michael Kennedy: or on most of the social media.
Michael Kennedy: There's the links at the top of the show notes.
Michael Kennedy: Join us live right now, Monday, just after 10 o'clock.
Michael Kennedy: Typically, it's when we start live streaming,
Michael Kennedy: although sometimes it varies.
Michael Kennedy: So subscribe to the YouTube channel
Michael Kennedy: and get notified there to make sure you get all the notifications.
Michael Kennedy: But typically we aim for Monday at 10
Michael Kennedy: until further notice at least.
Michael Kennedy: And finally, subscribe to the newsletter.
Michael Kennedy: We're putting a lot of effort into sharing
Michael Kennedy: a really nice, rich, extra bits of information
Michael Kennedy: out to the newsletter there every week.
Michael Kennedy: So appreciate that going out.
Michael Kennedy: And I think it's been,
Michael Kennedy: we put a lot of work into this, Brian.
Michael Kennedy: I mean, a lot.
Michael Kennedy: So I'm ready for a rest.
Michael Kennedy: Take a little rest.
Michael Kennedy: How about you?
Brian Okken: Yeah, yeah.
Brian Okken: We should take a rest.
Brian Okken: maybe with a REST framework.
Michael Kennedy: Oh, because sometimes you need a whole framework to REST.
Michael Kennedy: You're that tired.
Brian Okken: Yeah, so let's pop this up.
Brian Okken: So we've got an article.
Brian Okken: This is sort of going backwards
Brian Okken: because there's a new package out
Brian Okken: that I want to talk about,
Brian Okken: but it's based on this article from Emma Levitt.
Brian Okken: Why in 2025 do we still need a third-party app
Brian Okken: to write a REST API with Django?
Brian Okken: So and third-party apps we're talking about is usually Django REST framework or Django Ninja.
Brian Okken: Increasingly more people are reaching for Django Ninja.
Brian Okken: But, you know, both are great choices.
Brian Okken: And but still, like, why do we have to have an extra REST framework with if you already have Django?
Brian Okken: And the basically the gist of this article is, no, you can you can create and with all the built ins.
Brian Okken: And this is using the class-based views to build a CRUD app, a CRUD API with Django.
Brian Okken: And I actually kind of love this.
Brian Okken: There's comments at the end also.
Brian Okken: I kind of love the article talking about doing everything that's necessary to, it's not that much,
Brian Okken: it's just not that much code to create a JSON REST API through, yeah, through Django without anything extra.
Brian Okken: And down in the comments, some of the folks are like, well, why would you do this if you already have these others?
Brian Okken: And of course, it's that you can.
Brian Okken: That you can, but also that when you understand how you could build it with just the tools here, then it helps you understand how to use the other tools like Django Ninja.
Brian Okken: So the reason why I'm bringing this up now, this is this, I think this article was from like March, April or something like that.
Brian Okken: But she went ahead and DJ Rest 2 is now available.
Brian Okken: And that is, if you scroll down to the bottom of it, it is her, is designed to be a minimal yet powerful Rest framework.
Brian Okken: but it's around this article of why do we need an external app for REST,
Brian Okken: which is kind of funny that she created an external app for REST too,
Brian Okken: to demonstrate that.
Brian Okken: But it's all the code from there.
Brian Okken: And it's really great to be able to learn about REST frameworks
Brian Okken: through trying something smaller scale.
Brian Okken: So I like it.
Brian Okken: Awesome.
Brian Okken: Yeah, I'm with her on this.
Michael Kennedy: You don't necessarily need a framework.
Michael Kennedy: I know there's great frameworks.
Michael Kennedy: like there's FastAPI and others and no shade on those things.
Michael Kennedy: But if you already have a web app, you already have a framework that is serving web stuff.
Michael Kennedy: And do you really want to say, well, now we're going to do a completely different one because
Michael Kennedy: I need the response to be JSON?
Speaker 3: Not necessarily, right?
Michael Kennedy: It's all the APIs that power the talk Python mobile app are written in pyramid.
Michael Kennedy: They're not using FastAPI because the whole app was already pyramid.
Michael Kennedy: The data, everything it needs to know about the users and the data and the course, it's
Michael Kennedy: all in there.
Michael Kennedy: And all I had to do is write a JSON serializer that would take a dictionary and turn into the right kind of JSON.
Michael Kennedy: And literally, I have an API.
Michael Kennedy: You know, a lot of these frameworks, I don't like them.
Michael Kennedy: I'm not knocking on any particular.
Michael Kennedy: But these add rest to your thing so often become what that means is an HTTP view of your database.
Michael Kennedy: Like, here's how you do get, post, put, and delete to rows in this table.
Michael Kennedy: And then, you know, it's like, okay, that's not the way I want to structure my.
Michael Kennedy: I don't want to just give my database to like the world.
Michael Kennedy: I want to have control over actions that you take,
Michael Kennedy: like authenticate.
Michael Kennedy: And that's not like just access to the table,
Michael Kennedy: you know, it's weird.
Michael Kennedy: So I don't know.
Michael Kennedy: I find them not to be,
Michael Kennedy: I know it's like,
Michael Kennedy: well, we absolutely have to reach for a rest thing.
Michael Kennedy: I don't know that that's necessarily true.
Brian Okken: It's also very true that you don't like,
Brian Okken: you don't really need a full framework
Brian Okken: if really you're the client.
Brian Okken: If, I mean, I would say,
Brian Okken: I would probably lean on others to create a better API
Brian Okken: or better experience if that's the product,
Brian Okken: if the API is the product.
Brian Okken: But if the product is your website
Brian Okken: and you've got a framework, you're using Django,
Brian Okken: you've got a database there,
Brian Okken: but you have something else that wants to access that data
Brian Okken: so that you're presenting some extra endpoints.
Brian Okken: If you just have a couple of endpoints
Brian Okken: that you need to create to get some data out
Brian Okken: or push some data in,
Brian Okken: you don't necessarily need the full-blown extra framework.
Brian Okken: I think something simple would work just fine.
Brian Okken: Yeah, for sure.
Brian Okken: Yeah.
Brian Okken: Well, let's get out of the web a little bit
Brian Okken: and maybe go to the command line.
Brian Okken: I'm going to spend a lot.
Michael Kennedy: I basically have a theme running through this,
Michael Kennedy: my picks, my topics for the day.
Michael Kennedy: So use git on the command line, I'm sure, Brian.
Michael Kennedy: Yeah.
Michael Kennedy: A little bit of git add, dot, git push, all those things.
Michael Kennedy: I'm a big fan of using the GUI tools,
Michael Kennedy: especially the tools built into your IDE,
Michael Kennedy: you know, PyCharm and VS Code plus derivatives.
Michael Kennedy: That means like 20 different things these days.
Michael Kennedy: They have really fantastic tools.
Michael Kennedy: And I don't rarely, I rarely feel the need,
Michael Kennedy: like I got to be in the command line to mess with it,
Michael Kennedy: but I still do plenty.
Michael Kennedy: That said, where I haven't been doing a lot of stuff
Michael Kennedy: in the command line is at the GitHub level.
Speaker 3: Oh, right, yeah.
Michael Kennedy: Right, like you're like, okay, I'm going to git push, get pull.
Michael Kennedy: Oh, there's a PR, I need to check that out.
Michael Kennedy: what is the command again to check out that PR?
Michael Kennedy: Or I want to refer to an issue.
Michael Kennedy: How do I do that?
Michael Kennedy: Like, what was the number of it again?
Michael Kennedy: Because there's really cool things in Git.
Michael Kennedy: You can say Git commit.
Michael Kennedy: And for the message, you can say,
Michael Kennedy: fixes or resolves number one, two, three.
Michael Kennedy: And that'll literally associate the commit
Michael Kennedy: with the issue one, two, three, and close it
Brian Okken: when you push it into the server.
Brian Okken: Which sometimes surprises me.
Brian Okken: But yeah, it's good to know.
Michael Kennedy: Yeah, I've accidentally put an issue in a PR,
Michael Kennedy: but then close the PR and it's closed issue.
Michael Kennedy: I'm like, no, no, no, that's actually,
Michael Kennedy: we're not done yet, hold on.
Brian Okken: Look, doesn't quite resolve blah.
Brian Okken: Whoops.
Brian Okken: Yeah, then it actually closes it.
Michael Kennedy: You got to reopen it.
Michael Kennedy: Whoopsie.
Michael Kennedy: Anyway, so what I want to talk about today
Michael Kennedy: is the GitHub CLI.
Michael Kennedy: So I don't know how long this has been around,
Michael Kennedy: well, presumably, but I think it's pretty new.
Michael Kennedy: And so the idea is you can ask for status of PRs
Michael Kennedy: or you can check out,
Michael Kennedy: Like this one's really nice.
Michael Kennedy: GHPR checkout 12.
Michael Kennedy: That's it.
Michael Kennedy: It's all you got to do.
Michael Kennedy: And it's figured out the branches.
Michael Kennedy: It's pulled it.
Michael Kennedy: It's checked out the right one, right?
Michael Kennedy: That's really cool, isn't it?
Michael Kennedy: Oh, yeah.
Michael Kennedy: Yeah.
Michael Kennedy: So to get a sense of what's possible, because when I saw this, I'm like, I think this will
Michael Kennedy: be cool, but why?
Michael Kennedy: Look at the manual.
Michael Kennedy: And the manual has example usages.
Michael Kennedy: That's how I would start to look.
Michael Kennedy: So it says, I could check out a pull request locally.
Michael Kennedy: And it's the one that I just said.
Michael Kennedy: Boom.
Michael Kennedy: Right.
Michael Kennedy: Pretty neat.
Michael Kennedy: You can do it by branch name.
Michael Kennedy: You can clone a repository with just the owner and repo.
Michael Kennedy: So you could say ghrepo clone, you know,
Michael Kennedy: Mike C. Kennedy slash Jinja dash partials or whatever.
Michael Kennedy: You don't have to know the whole URL.
Michael Kennedy: It's not that huge of a thing, but it's kind of nice.
Michael Kennedy: You can also clone it as if you were doing git clone,
Michael Kennedy: but you like to type gh-based repo instead of git.
Michael Kennedy: I don't know.
Michael Kennedy: You can create PRs from a branch, which is pretty cool.
Michael Kennedy: And it just asks you what's the title, what's the body, and so on.
Michael Kennedy: You can open up the browser, like take me to GitHub.
Michael Kennedy: You can mess with forks.
Michael Kennedy: What else can you do?
Michael Kennedy: Yeah, you can see issues like GitHub PR list.
Michael Kennedy: It'll show you whether they're open, who they're associated with.
Michael Kennedy: Same thing for issues.
Michael Kennedy: It even puts the tag in parentheses, parenthetically tags it.
Michael Kennedy: I love it.
Michael Kennedy: Anyway, I think this is kind of handy.
Michael Kennedy: What do you think?
Brian Okken: Yeah, you can do releases too, right?
Brian Okken: Did you already comment on that?
Michael Kennedy: I have not commented on that.
Brian Okken: Because that's often the thing that I need to,
Brian Okken: like I've got everything all automated.
Brian Okken: except for I still go over to GitHub itself
Brian Okken: to create a release item or release.
Michael Kennedy: Yeah, I do too.
Brian Okken: So being able to do that locally, that's pretty cool.
Michael Kennedy: I've got the generation of the release notes automated
Michael Kennedy: and the tagging of the branch automated,
Michael Kennedy: but I still can't release it automatically.
Michael Kennedy: You know what I mean?
Brian Okken: Now you can do it, at least do it on the command line.
Michael Kennedy: A little bit more.
Michael Kennedy: That's awesome.
Michael Kennedy: Anyway, check this out if you're a CLI person,
Michael Kennedy: you know, GH, your new command.
Brian Okken: Yeah, so go figure.
Brian Okken: that you're the command line person today
Brian Okken: and I'm the web person.
Brian Okken: So we're going to hop back over the web
Brian Okken: and talk about web scraping.
Brian Okken: So, and web scraping is, you know, not evil.
Brian Okken: Sometimes it's, especially if there's no API,
Brian Okken: it might be the only way to get some data from something.
Brian Okken: So there's a project that I found out on Reddit
Brian Okken: called Can I Scrape, which is sort of a fun name.
Brian Okken: And it basically analyzes the website's anti-bot protections to let you know whether or not you should even try to build a scraper for it or how many roadblocks you're going to run into.
Brian Okken: And also, I think it's just sort of, I don't know, it seems like kind of a nice thing to do instead of to check all the rules out and stuff.
Brian Okken: So it looks for protections like, I don't know what WAF is, but captures and rate limits, honeypots.
Brian Okken: And then it rates it a difficulty score from zero to 10, easy to hard, and specific recommendations on what tools or proxies you'll need and the estimated complexity to build it.
Brian Okken: that would be a decent thing to use on your own stuff if you are intending somebody,
Brian Okken: if you just tell somebody, oh, I don't have an API for that, but go scrape the data.
Speaker 3: What kind of a job are you asking them to do?
Brian Okken: And I was like, I didn't see right away a comment on the robots,
Brian Okken: but looking down through it, what it analyzes, it does check the robots.txt to make sure that you can.
Brian Okken: And that's one of the things I want to be careful of somebody's,
Brian Okken: what they say you should do and not do with their website.
Brian Okken: So that's cool.
Brian Okken: And anyway, I just thought it was nice.
Brian Okken: There's an interesting discussion on the link to the Reddit discretion as well.
Brian Okken: Just a target audience of hobbyists, but also just like data people.
Brian Okken: Like sometimes there's data that's available on the web that, like I said,
Brian Okken: no, there's no REST API yet for it or there won't be.
Brian Okken: But yeah, anyway.
Michael Kennedy: Yeah, I love it.
Michael Kennedy: Very interesting.
Michael Kennedy: This whole web scraping thing is getting more and more contentious with AI training and all of that.
Michael Kennedy: It's good to be a good citizen of the web.
Brian Okken: Yeah.
Brian Okken: And also, like, maybe I'd possibly use some of these to check your own.
Brian Okken: If you want to lock it down, if you really want to make, if you want to make scraping a real pain in the butt for people looking at your website, you know, you can use this to try to make your score as close to 10 as possible.
Michael Kennedy: Exactly.
Michael Kennedy: All right.
Michael Kennedy: That's not what I want to talk about.
Michael Kennedy: That's what I want to talk about next.
Michael Kennedy: So I want to talk about Git, a totally different tool, though.
Michael Kennedy: This is completely unrelated to the other one.
Michael Kennedy: Okay, so I launched this CLI tool.
Michael Kennedy: It's on PyPI, but primarily is intended to be used as a CLI type of thing,
Michael Kennedy: like rough, not to be built upon, but to be run.
Michael Kennedy: You know what I mean?
Michael Kennedy: So you can uv tool install it.
Speaker 3: And the idea is I called it Giddyup, G-I-T-T-Y.
Michael Kennedy: for updating your, a whole directory tree of GitHub repositories.
Michael Kennedy: Okay.
Michael Kennedy: I may have talked about this before, something I kind of built like in passing.
Michael Kennedy: And then I was, last week I decided I'm creating a new course,
Michael Kennedy: Agentic AI programming in Python.
Michael Kennedy: How about that?
Speaker 3: And I'm like, let me think of something I can try to take that I know is a cool idea
Michael Kennedy: that would seem plausible, but really just make it a super nice app.
Michael Kennedy: Add a bunch of features and so on.
Michael Kennedy: So I took that little utility I had and I spent a lot of time with CloudSonna and Giddyup
Michael Kennedy: is the output.
Michael Kennedy: So it says, never forget to pull again.
Michael Kennedy: Automatically discover and update all your GitHub repositories in one command.
Michael Kennedy: So here's the thing.
Michael Kennedy: I've got three computers, one of them is a laptop, and they all have a bunch of GitHub
Michael Kennedy: repositories, like hundreds of GitHub repositories.
Michael Kennedy: And it drives me crazy.
Michael Kennedy: I'll go to some older one I haven't worked with for a while.
Michael Kennedy: Like, I don't think there's been any change to this.
Michael Kennedy: And I'll start messing with it.
Michael Kennedy: Then I'll try to push it.
Michael Kennedy: It'll go, please pull your changes first.
Michael Kennedy: I'm like, uh-oh, uh-oh, that's not good,
Michael Kennedy: especially if it's something to do with the courses
Michael Kennedy: where it might be a PowerPoint that cannot be merged.
Michael Kennedy: You know what I mean?
Michael Kennedy: You're like, oh, no, this is real bad.
Speaker 3: And it's out of date, right?
Michael Kennedy: And so I created this thing so I can just,
Michael Kennedy: especially before I grab my laptop and head off to the coffee shop,
Michael Kennedy: I can just go into part of my GitHub repos and just say, Giddyup.
Michael Kennedy: And it goes through in parallel,
Michael Kennedy: and it just looks at all the repositories.
Michael Kennedy: Does it get pull on all the ones that don't have anything checked out?
Michael Kennedy: And the ones that are not committed yet,
Michael Kennedy: It says, hey, I don't want to mess with this one.
Michael Kennedy: It has these three files unchanged and so on.
Michael Kennedy: So it's just like a nice little utility people can run to update all their code.
Michael Kennedy: I'll see if I can find a little output down here.
Michael Kennedy: It's got a ton of features.
Michael Kennedy: But yeah, I'd say update this thing,
Michael Kennedy: and it traverses hierarchically through all the GitHub repositories.
Michael Kennedy: It says these are up to date.
Michael Kennedy: I actually pulled a couple commits for this one.
Michael Kennedy: This one had an error, and it just gives you,
Michael Kennedy: basically gets all of your GitHub repositories as much in sync
Michael Kennedy: across all the branches as much as possible
Michael Kennedy: without breaking anything.
Michael Kennedy: Oh, cool.
Michael Kennedy: Yeah, so anyway, I put that out there for you.
Michael Kennedy: I think people might like it.
Michael Kennedy: I didn't, I just put it out there two days or three days ago
Michael Kennedy: and it's already got some stars and forks
Michael Kennedy: and I haven't announced it at all whatsoever,
Michael Kennedy: not even on social media.
Michael Kennedy: So people found it and started, that's cool.
Michael Kennedy: Yeah, nice.
Michael Kennedy: All right, so GittyUp.
Brian Okken: I have a feeling that maybe people watch your repo
Brian Okken: a little bit.
Michael Kennedy: I think that's what it is, like the GitHub.
Michael Kennedy: And to be honest, I am a super fan of just clicking on the GitHub logo and going and just looking at what's flowing by.
Michael Kennedy: I'm starting to follow more and more people.
Michael Kennedy: I appreciate people following me.
Michael Kennedy: That's a really nice source of just, hey, what's interesting?
Michael Kennedy: Because if people you follow star something, that shows up.
Michael Kennedy: You're like, oh, this person found that interesting enough to star it.
Michael Kennedy: And I definitely respect what that person is doing.
Michael Kennedy: Let me go check this out.
Michael Kennedy: That does look interesting.
Brian Okken: I'm sure that's how people found it.
Brian Okken: Okay, cool.
Brian Okken: Yeah, cool.
Brian Okken: Well, I want to bring up something that I've apparently spent a lot of time thinking about.
Brian Okken: So we're done with our normal stuff, right?
Brian Okken: We are.
Brian Okken: Moving on to extras.
Brian Okken: Do you want to do your extras first?
Michael Kennedy: Sure.
Michael Kennedy: I'll be quick about mine.
Michael Kennedy: Okay.
Michael Kennedy: Yeah, let's do yours.
Michael Kennedy: Let me close this off.
Michael Kennedy: Yeah, check out that Agentic AI programming course.
Michael Kennedy: It's coming out this week.
Michael Kennedy: But people listened.
Michael Kennedy: And I don't know if they actually listened to us.
Michael Kennedy: I think they listened to other people with the same complaint.
Michael Kennedy: But remember how last week on PyDay, I said, great, but uv loop doesn't work with Python 3.14.
Michael Kennedy: Well, I'm so happy to tell you as of four days ago, uv loop is back, baby.
Michael Kennedy: And we can use it again, which mostly is awesome because I don't want to go change a bunch of projects that were just fine.
Michael Kennedy: But if I were to swap out the foundation running them like to 3.14, they wouldn't run anymore.
Michael Kennedy: So now it's back.
Michael Kennedy: So there's a release for that.
Michael Kennedy: So uv loop, while it was gone from us for a little bit, it's back.
Michael Kennedy: And remember how I said, I wish I knew who created PyPI plus and how neat it was, because
Speaker 3: it has just these few little gotchas that I would love to like polish it.
Michael Kennedy: Well, they sent over a message and said, thank you so much for a feature in PyPI plus, and
Michael Kennedy: I'm working on the bugs that you found.
Michael Kennedy: I don't know how they heard that we were maybe their show listener or someone they know is
Michael Kennedy: a listener of the show.
Michael Kennedy: But yeah, look at this.
Michael Kennedy: I can search for something with a dash and I get the lowercase and vice versa.
Brian Okken: Oh, cool.
Brian Okken: But also, there's some people that maybe don't have a Python podcast to complain about things.
Brian Okken: Is there like a about us or who are we?
Brian Okken: There is.
Michael Kennedy: I believe I put it in, you know, the best way would be a Reddit, I believe.
Michael Kennedy: So Royal Wizard is the one who they initially announced it on Reddit and so on.
Michael Kennedy: So you could, and they seem to be talking about the changes and the features over on
Michael Kennedy: slash r you know r slash python so that's probably the best way okay yeah cool and then finally i you
Michael Kennedy: know i told you about my host show me your ls which looked like show me your is because of the fonts
Michael Kennedy: well people uh sent some feedback and i just wanted to share one because this is a common theme over
Michael Kennedy: and over thomas spenson uh said hey i'm currently using new shell which for some reason i read as a
Michael Kennedy: nutshell and went about talking about it that stuff that was the thing but said hey i'm currently using
Michael Kennedy: and exploring New Shell, and its LS is something else clever.
Michael Kennedy: So you can just kind of do almost query syntax against things like LS,
Michael Kennedy: structured data, PS, JSON, et cetera.
Michael Kennedy: So like, look at this.
Michael Kennedy: This is crazy, right?
Brian Okken: Yeah.
Michael Kennedy: And following on, found out today that New Shell is using Polars
Michael Kennedy: and that plugins can be written in Python.
Michael Kennedy: So even cooler.
Michael Kennedy: I'm not doing anything with New Shell.
Michael Kennedy: I literally had never heard of it.
Michael Kennedy: It's that new.
Michael Kennedy: No, I don't know.
Michael Kennedy: I hadn't heard of it before I wrote that article,
Michael Kennedy: but it does seem pretty interesting.
Michael Kennedy: I am not here necessarily to switch to it,
Michael Kennedy: but look at this.
Michael Kennedy: LS pipe, where size greater than 10 megabytes,
Michael Kennedy: pipe sorted by, modified.
Michael Kennedy: Boom.
Michael Kennedy: I can see that as powerful.
Brian Okken: Yeah, that's pretty cool.
Brian Okken: All right, that's it for my extras.
Brian Okken: Yeah, and I really would like to try new stuff.
Brian Okken: For me, well, I'm using Mac, Windows, Linux,
Brian Okken: all sorts of stuff,
Brian Okken: And trying to get, so to be fair, I just sort of use,
Brian Okken: obviously I use Z shell on Mac because that's what it comes with.
Brian Okken: But I kind of just use the bash version of stuff because it's common denominator
Brian Okken: over everything. Anyway. But that's, you know, just me griping.
Brian Okken: I want to talk about something old or new or not yet. Lazy imports.
Brian Okken: So two episodes ago, we talked about a PEP 8, 10 explicit lazy imports.
Brian Okken: And I was super excited about it coming in 3.15, but it's still in draft mode, so we don't know if we'll get it.
Brian Okken: And then last week, I talked about if you want to use lazy imports right now, how you can do it just with Python, of just throwing the import in the first function before you start using it.
Brian Okken: And then, but there's some other people thinking about lazy imports and how cool they would be also.
Brian Okken: So Hugo wrote an article called Three Times Faster with Lazy Imports.
Brian Okken: This is, and actually, wow, this is something I don't have the capacity to do.
Brian Okken: I probably would maybe, but anyway, of just implementing it.
Brian Okken: So there's a, he did a, he fetched the CPython.
Brian Okken: There's apparently a lazy import reference implementation included in the PEP.
Brian Okken: So he built Python with the patch and then also released it as if it was 314 so that he could get away with not building a whole bunch of other stuff.
Brian Okken: And then went ahead and did some, Hugo does the PyPI stat stuff, which I love that tool.
Brian Okken: And he did a pip dep tree and did some lazy import stuff on it to see if it would speed it up.
Brian Okken: And his benchmarks look very promising.
Brian Okken: speeds it up quite a bit.
Brian Okken: 1.31 times faster for one implementation.
Brian Okken: And then kept going.
Brian Okken: And let's see.
Brian Okken: I can't remember what this last one is.
Brian Okken: We no longer need inline imports trick.
Brian Okken: Anyway, a couple of different things he tested.
Brian Okken: Either way, it's faster to use it.
Brian Okken: So I'd be excited to get that in.
Brian Okken: However, somebody else.
Brian Okken: So there's a great thread also, we'll link to it,
Brian Okken: a great thread on Mastodon, which I clicked on accidentally,
Brian Okken: to talk about between Graham and him and others about his implementation.
Brian Okken: Okay, so top imports 105, the normal imports 105 milliseconds.
Brian Okken: Inlining, which is essentially what I'm teaching people to do in my post,
Brian Okken: 46 milliseconds, so that drops it down quite a bit.
Brian Okken: Then there's the wrapped lazy import version,
Brian Okken: which I'm going to talk about in a second.
Brian Okken: that drops it down to 41.
Brian Okken: And then using 810 drops down to 35.
Brian Okken: So there's, I guess that's it.
Brian Okken: So he timed a whole bunch of stuff
Brian Okken: and talks about it in the article.
Brian Okken: Like 3x speed up with the,
Brian Okken: if we put it in 315, that's awesome.
Brian Okken: Yeah.
Brian Okken: And he's timing PyPI stats with help.
Brian Okken: So the help is supposed to be really fast
Brian Okken: and not actually do anything.
Brian Okken: So, and that's kind of a cool way
Brian Okken: to test it is you're running your application
Brian Okken: or your command line application,
Brian Okken: but not actually doing work.
Brian Okken: It shouldn't import the world then, right?
Brian Okken: So.
Brian Okken: Yeah.
Michael Kennedy: Even if it does a decent amount of work,
Michael Kennedy: it probably doesn't need all the imports.
Brian Okken: Yeah.
Brian Okken: Right.
Brian Okken: And if you're doing some work,
Brian Okken: you might not need other imports,
Brian Okken: those sort of things.
Brian Okken: Those are good things to do.
Speaker 3: So, and going back again,
Brian Okken: reminding people the idea around this explicitly imports
Brian Okken: is to mark some imports to say,
Brian Okken: Don't actually import this until the first instance of somebody trying to use it.
Brian Okken: That gets imported.
Michael Kennedy: Graham.
Brian Okken: I just, go ahead.
Brian Okken: No.
Michael Kennedy: I just timed GittyUp-help, which I installed via uv tool install.
Michael Kennedy: 60 milliseconds.
Michael Kennedy: I'm pretty impressed with that.
Michael Kennedy: That's really fast.
Michael Kennedy: Yeah.
Michael Kennedy: But you know what?
Michael Kennedy: The help in the CLI arg parsing type stuff is built with arg pars.
Brian Okken: So there's not a bunch of external stuff to pull in.
Brian Okken: Yeah, I'm using arg pars more and more now.
Brian Okken: Okay, so Graham was in the discussion thread and Graham Doubleton, and he also wrote a blog post called, wow, it just came out today.
Brian Okken: Cool.
Brian Okken: Use or updated today.
Speaker 4: Beat the music just off the wire.
Brian Okken: Use lazy module imports now.
Brian Okken: And then this case is not the inline one.
Brian Okken: And he's using the wrapped.
Brian Okken: There's a wrapped package that is for decorators, wrappers, and monkey patching.
Brian Okken: It's one of his packages.
Brian Okken: And it can be used to kind of simulate lazy imports also.
Brian Okken: Which, it's the syntax.
Brian Okken: So it's kind of a cool article.
Brian Okken: And the syntax is different.
Brian Okken: So again, the lazy imports, if we get it in 3.15, it'll look like that.
Brian Okken: lazy import json or lazy from json import something um the wrapped version is uh import wrapped and
Brian Okken: wrapped dot lazy import so apparently wrapped has a lazy import feature which is cool um and uh but
Brian Okken: the syntax is a lot different so i'm i'm not sure what i was what i think about that and then also
Brian Okken: down at the bottom adam johnson reached out to him and said uh type checking kind of breaks when
Michael Kennedy: you're using yeah so you know what i think you might be able to actually fix it i wonder if you
Michael Kennedy: could could you know probably i was saying that you could say json colon type is json but important
Brian Okken: but then it's it's not going to know what that is yeah you're right it that was my thought when i
Michael Kennedy: saw this as like oh it'd be fun to play with lazy imports i'm like oh but that's going to destroy
Brian Okken: type information in the editors right so that's where um adam's suggestion of saying if
Brian Okken: type yet checking import json so just go ahead and actually import all the stuff if you're type
Brian Okken: And that'll probably help the editors, I imagine.
Brian Okken: So.
Michael Kennedy: Wow.
Michael Kennedy: Here's the one for the 315, because I love this idea as well.
Michael Kennedy: And I appreciate Hugo writing up all the research.
Brian Okken: Yeah.
Brian Okken: So, and also Graham for talking about how to get around it with rap to that school.
Brian Okken: So, and a little faster than my man.
Brian Okken: All right.
Brian Okken: I'm feeling lazy still, but how about funny?
Brian Okken: Do we got something funny?
Brian Okken: Oh, yeah.
Michael Kennedy: I got something.
Michael Kennedy: Actually, really, really quick real-time follow-up, because, I mean, we're covering stuff that
Michael Kennedy: came out today.
Michael Kennedy: And who doesn't love to hear that AWS US East 1 in Virginia went down?
Michael Kennedy: So right here on CNN, by the way,
Michael Kennedy: AWS services are recovering again after a global internet outage.
Michael Kennedy: Scroll down a little bit.
Michael Kennedy: Somewhere about East.
Michael Kennedy: There we are.
Michael Kennedy: It seems like a third of the world is hosted in US East 1.
Michael Kennedy: But you know what?
Michael Kennedy: Our stuff is clipping along smoothly just as it should.
Michael Kennedy: All right. So good luck to everyone who's running over there. So here's the thing, Brian, for the joke. Are you more of a fantasy person? Are you more of a science fiction? Or what's your genre of big epic storytelling?
Brian Okken: Well, sci-fi usually.
Brian Okken: I listen to a lot of science books right now.
Michael Kennedy: But yeah.
Brian Okken: Yeah, I'm personally a science fiction person.
Michael Kennedy: I definitely take a science, a giant space sort of thing, interstellar type of thing over, say, dragons and witches.
Michael Kennedy: But I think you might appreciate this.
Michael Kennedy: So Lord of the Rings, okay?
Michael Kennedy: There's Gandalf and there's Frodo.
Michael Kennedy: And it says, Gandalf, they've discovered something together.
Michael Kennedy: And Gandalf looks over at Frodo and says, what can you see?
Michael Kennedy: it's it's some form of elvish i i can't read it and he's holding a regular expression
Speaker 4: slash carrot for the z question mark equals dot percent backslash d is like
Brian Okken: some form of elvish can't read it yeah nobody can pretty good right yeah that is good i've seen the
Michael Kennedy: same meme but with uh if double underscore name or dunder name equal equal dunder main it's like
Michael Kennedy: It's some form of Lfish.
Michael Kennedy: I can't read it.
Speaker 4: It's great.
Speaker 4: It doesn't make sense.
Speaker 4: How can you not read that?
Brian Okken: But also, it seems odd still that that's the way we can tell if you're running an application
Brian Okken: directly or it's getting imported.
Michael Kennedy: I know.
Michael Kennedy: It works, but it's just a weird convention.
Michael Kennedy: I'm totally here for just the main function, static main void or the variations across so
Michael Kennedy: many different applications.
Michael Kennedy: I mean, that's actually what I end up writing in my code is I always have a def main something or async def whatever main.
Michael Kennedy: And then in the Dunder name equal Dunder main, I just call main.
Michael Kennedy: And that's just like, this is my convention.
Michael Kennedy: The main thing goes at the top.
Michael Kennedy: It's called main.
Michael Kennedy: That's how the app starts.
Michael Kennedy: But I still got to go to that little wire together deal at the end.
Brian Okken: Yeah.
Brian Okken: It seems like we should have like a if like if not imported or something, because that's essentially what we're saying.
Brian Okken: But anyway.
Brian Okken: One of the things I noticed, I really enjoy sci-fi, but I realized that a lot of the sci-fi books that I love still have, like, talk about, like, in the future, we'll have new technology and it's going to suck because of XYZ.
Brian Okken: It's like, there's not a lot of optimistic sci-fi.
Brian Okken: It's a lot of dystopian, yeah.
Michael Kennedy: Yeah.
Brian Okken: Anyway.
Michael Kennedy: Sure, we have cool spaceships, but we've destroyed the world, so we have to use them to go find a new world to destroy.
Brian Okken: Yeah, yeah.
Brian Okken: And we still have politics in space.
Brian Okken: But anyway.
Brian Okken: But no politics on this episode.
Michael Kennedy: No, unless you don't feel like we're bashing elvish writing, but that's okay.
Brian Okken: Yeah.
Michael Kennedy: All right.
Michael Kennedy: Thanks for being here.
Michael Kennedy: Thanks to everyone for listening.
Michael Kennedy: We appreciate it.
Michael Kennedy: Bye, y'all.
Brian Okken: Bye.