We're sunsetting PodQuest on 2025-07-28. Thank you for your support!
Export Podcast Subscriptions
cover of episode #421 22 years old

#421 22 years old

2025/2/24
logo of podcast Python Bytes

Python Bytes

AI Deep Dive Transcript
People
B
Brian
Python 开发者和播客主持人,专注于测试和软件开发教育。
M
Michael
帮助医生和高收入专业人士管理财务的金融教育者和播客主持人。
Topics
Michael: 我介绍了httpdbg,一个用于调试Python程序中HTTP(S)客户端请求的工具。它易于使用,只需用pyhttpdbg命令代替python运行程序即可。它提供了一个UI界面,可以查看、比较和分析应用程序发出的所有HTTP请求,这对于调试和学习HTTP请求的运作方式都非常有用。它支持多种HTTP库,包括requests, urllib, httpx, aiohttp等,甚至可以拦截其他库发出的HTTP请求,这使得它成为一个非常强大的调试工具。 Michael: 我还讨论了Anaconda在推动Python移动端开发方面所做的努力。PyPI现在支持iOS和Android平台的预编译二进制包(wheels),这使得在移动设备上安装和使用Python库更加容易。Anaconda的Russell Keith-McGee在其中发挥了关键作用,他致力于使iOS和Android成为CPython的官方构建目标。CI Build Wheel工具也正在更新中,以简化iOS和Android wheels的创建过程。 Michael: 最后,我还分享了我用旧的Mac mini以175美元的价格换购了一台全新的Mac mini M4的经历,这让我感到非常惊喜。 Brian: 我介绍了PyPI现在支持iOS和Android wheels的消息,这标志着移动端Python开发向前迈进了一大步。这要感谢Sarah Gooding和Russell Keith-McGee等人的努力,以及PEP 730和738的推动。虽然CI Build Wheel工具目前仍在更新中,但它将进一步简化iOS和Android wheels的创建过程。这将使越来越多的第三方库能够在移动设备上使用。 Brian: 我还讨论了Arcade游戏平台的3.0版本发布。这个版本带来了许多改进,包括对OpenGL和ShaderToy的支持,以及对Python 3.8的支持终止。虽然有一些breaking changes,但总体上这是一个非常重要的更新,为游戏开发者提供了更多功能和效率。 Brian: 最后,我介绍了PEP 765的接受,该PEP禁止在finally块中使用return、break和continue语句来退出finally块。虽然这不会立即成为语法错误,而是一个语法警告,但这将有助于避免一些意外的行为。

Deep Dive

Shownotes Transcript

Translations:
中文

Hello and welcome to Python Bytes where we deliver Python news and headlines directly to your earbuds. This is episode 421, recorded February 24th. I'm Brian Ocken. I'm Michael Kennedy. This fabulous episode is sponsored by all of you folks that support us at maybe taking a course over at TalkPythonTraining or heading to pythontest.com, learn about PyTest, maybe taking a course.

We also love our Patreon supporters, so thank you. If you'd like to connect with us, of course, you can check. There's six links in the show notes for the show and me and Michael over at Blue Sky or Fostadon or Mastodon. So keeping track of both of those. And if you'd ever like to jump into the show live, you can head to pythonbytes.fm slash live and check out when the next...

And the next recording will be, and you can be with us and ask questions and stuff. And it's fun. And finally, um, the newsletter is still going out. Um, and, um, Michael's made some improvements to it. So, uh, we're, we're, we're making some, some neat things. And I think it's a really cool resource. Now, um, if you are, especially if, if sometimes you listen to the show and you're like, that

That seems like a cool topic, but I don't quite know much about that thing that they're talking about. We're including some background information. So if you'd like to learn more about the topic, we're including a lot of links and that's really cool. Yeah, super fun. Yeah. Speaking of super fun, what's your first topic for us, Michael? You know what is super fun? Debugging is super fun.

Because testing is sometimes fun, but debugging, that's where the mysteries really live. You never know. And if you don't do much testing, you might do more debugging. You never know. Anyway, I want to talk about debugging HTTP calls. Now, one way in which you might do this is you might say, I have this well-factored piece of code over here, and I can call this function and we can, in isolation, test how it talks to some part, something else in the world, right?

And maybe we'll mock the HTTP layer out. We talked about REST, RSPX, which was a cool way to mock out HTTPX. And there's VCR and other things like that, which you might do. But this kind of allows you to intercept what's actually happening. You could use it during tests or you could use it just when your app is running. All the HTTP calls coming out of your Python app and then gives you a UI for understanding them. Pretty darn cool, I think.

Yeah. Okay. So what you do is the thing is called HTTP DBG for debug because those two vowels are hard work folks. And so HTTP debug,

tool is for Python developers to easily debug HTTP or HTTPS client requests in a Python program. All you got to do to use it is instead of saying Python my app, you say hi HTTP debug my app and it will sort of wrap and mock out all of the stuff. Mock is maybe not quite the right word because it still does the action. It's

sort of put an adapter or an intercepting layer on top of all your behaviors, right? Okay. Yeah, it's pretty cool. So you get this UI, and it shows you all the requests that your app has made, and then you can click on them, you can put them side by side and compare them, all those kind of stuff, which for the grand total effort of pip install and then run the process

run your code slightly differently, but it's, you know, that's a lot of, a lot of benefit and a lot of visibility into your app. So if you're doing things like maybe using Postman or something like that to kind of test out the calls and you try to replicate it over there and you're like, why is it not quite the same? Well, you know,

put this thing on it and see what happens. Yeah, I can also see this as a learning tool while you're just learning how all of this stuff gets put together. How does the request get... What does the data look like? And what's going on here? Yeah. It's pretty neat. Absolutely. Yeah, absolutely. And the other thing you can do...

is it, it's not just your direct HTTP calls, like say HTTPX or requests or something. If something else, a library you're using is then calling the API and it's not your library, you still get visibility into what that thing's doing. Because it's anything the application does, not anything that your code does, which is

Pretty cool. Yeah. So if you're using say the Sentry API and you're like, why is it failing to talk to this thing? Like, what is it even doing? You know, you just say capture exception, but you know, somewhere along the way, a HTTP request is being done. So you could intercept that as well. Like all the traffic. And I guess if you're like, is my thing spying on me?

Is this library that I'm using reaching out to something that I'm not aware of that's happening? You could also catch that theoretically. But it supports requests, URL lib, HTTPX, my fave these days, AIO HTTP, pip, pytest, unit test, and your package. Yes, if you include it. Anyway.

There's a, then when you run it, you get a web interface that gives you some behaviors in the UI. You can change the strategy to group requests. You can hide the scheme, the network URL, you can group rows, tags, all these different things. So there you have it folks. HTTP.

I think you're supposed to just say the initials like HTTP. This is hard. HTTPDBG. Yeah, possibly. Okay. Something a little easier to pronounce. PyPI now supports iOS and Android wheels for mobile Python development. This is cool, I think. This is very cool, yeah. So this is brought to us by Sarah Gooding and

So the announcement really is there's been some work. Russell Keith-McGee has been a longtime advocate to try to push this ball forward and get Python directly on devices better. So there's a couple of peps, 730 and 738, that talk about adding iOS and Android as a supported platform. So now their wheels are supported there. So how do we take advantage of this?

Well, there are some information in the article that we're linking to. But also, let's see, there's some tools that I've heard of Beware, and we've covered Beware and Kivy before. Then Chacopee, maybe? I don't know if we've covered that, but that's another one for Android. Yeah, that sounds new to me as well. I don't remember that one.

However, so you can either use these, but I was curious about like, so for pure Python stuff, if I want to be able, like if I'm not doing anything too fancy and I want to be able to have it be installable on one of these, what would I...

could possibly do. And CI Build Wheel is one of the tools that people have used before for other operating systems. And apparently that's not ready yet, but it is in the works. So CI Build Wheel updates are in progress to simplify iOS and Android wheel creation. So soon more and more third-party little libraries might be, and possibly big libraries might be available for us.

Yeah, that's awesome. I'm very excited for this. I think this is, you know, there's two areas of Python that are very troublesome, right? If

If someone comes to you and says, hey, I want to do some programming. What language are you using? Python, that's a great one. Yeah, so I'm looking to build a mobile app like this. Hold on, hold on. I totally retract my statement. You can't even, don't do that, is the one. And then the other is like Vue, React, other front-end JavaScript-y things, right? And what's cool is that the folks at Anaconda are actually really working hard to address both of those. And part of what we're seeing here is some of the work from them. I actually have...

And bumping over this way, I had Russell Keith McGee on, the guy behind Beware, to talk about the state of Python on mobile just, YouTube helped me out, five days ago. Wow. To talk about this. And he's been working, employed by Anaconda as part of their open source team for a couple years, solving these problems. Getting him and a guy named Malcolm are getting peps to have Python officially be available

to have iOS and Android and official build target of CPython, which is pretty interesting, right? Like we expect as part of the core developer process, we should be able to build it so that it runs on those platforms. And those peps I believe are accepted, but not necessarily in yet. So that's like upstreaming a lot of the work that Russell has done and they're using CI build will to make this happen. So a lot of interesting stuff happening there. Yeah. Yeah.

Cool. Yeah, I wasn't planning to talk about that episode, but since you brought it up, it sounds like if you guys are like, wait, what? What is all this about? You know, listen, I don't know that much, but Russell gives us the whole rundown last week, so you can check that out. I can't wait to listen. Yeah, definitely. Should be out soon. Okay. No joke. How about a game, though? Yeah, I like games. I'm ready for the gym. It popped up in my tab. But the game, so we got an

a notification from, I can't remember. Oh yes, Mayak Simering, who's working on Arcade, the game platform. And it hasn't had any major updates for a while until now. They just released 3.0 of Arcade. So if you are a huge fan of Mario Brothers type of 2D scrolling games, or you want to build something like Asteroid, you know, the game from the 70s,

that kind of UI, well, this is a really great platform for it. So what are the changes? Breaking changes, but you know, I guess that's expected after a while. Drop Python 3.8. Seems fine after, you know, the world has moved on from there. But texture management completely changed and

They used to cache everything. Apparently it was too much, but now you can reload and probably things are fast enough that you don't need caching. It works better. Like keep working memory in the graphics card or something better. Remove some stuff, fixed arcade context and so on. But, you know, mostly I want to put this out there as if you've been thinking of building like a 2D game type of thing and you're like, well, arcade's interesting, but it hasn't gotten a lot of love. Well, now it has, right? Last update yesterday. Pretty cool. Yeah.

If you want an example, there's some examples. Sorry, Ryan. There's some examples you can link to off of the Arcade Academy website. Go ahead. No, you said it hasn't had a lot of love in a long time, but it's still been...

I don't know if they needed to fix some things to get it to work on modern Python. Okay. Yeah, I'm not sure if they, I don't know that they necessarily did, but it just hasn't had any major releases, you know? Well, I'm noticing, so I've been doing that top pi test plugin thing and investigating a lot of the plugins. And there's a lot of stuff. I'm noticing there's a lot of stuff that used to be updated a lot. And for just to say, like in the trove classifiers to say, I support, you know, three, three, eight, three, nine, three, 10. And then they just sort of stopped.

But a lot of, I guess, try stuff out because Python has been pretty stable for a lot of things. And it's been, even though we've gotten some really cool things, it's still very backwards compatible. So...

There's a lot of old packages that don't say that they work on modern Python, like 3.13 or something, but still do. So don't dismiss a package just because it hasn't been updated for a while. Try it out. It might be fine. That's good advice. There's one thing where I can't remember if it was at Rust or some other platform, their equivalent of PyPI was they were automatically putting...

security warnings or something like that onto packages that had not had Git commit in two years. But you know, it might be done. There's a thing that could just completely do what it's supposed to do and not need to change. Anyway. Yeah. So you can check out the different kinds of games. I got some, a bunch of example games that you can play and,

And try it out. And they look pretty cool. Like, if you're looking for a, I don't want to use Unreal Engine and go completely down the higher team of 100 people to build a game. Yeah, it's fun. That looks pretty cool. It does look pretty cool. Yeah. Yeah, and I think it's OpenGL based. Pretty sure. Is that right? Yeah, it's built on top of Piglet and OpenGL. Yeah. So, use your graphics card for all sorts of fun stuff. Yeah. Yeah.

Yeah, I guess I'm on tangent mode right now. I guess I was thinking about games and a lot of people think I think a lot of kids get into like want to get into programming because they think game programming would be fun and game programming is hard.

And there's a lot of programming that's hard. But in game programming, there's a lot of stuff going on. And it doesn't necessarily-- don't get frustrated if you start game programming and it's a little difficult. And there's a lot of programming that's pretty straightforward. Yeah. I totally agree. Some of my first programming was 3D simulators in OpenGL. And it was not the easiest thing ever. In C++. Nice. OK.

Well, other things to not do is don't... Okay, I think I'm going to have too many negatives here. I just, I guess, want to announce that PEP 765 has been accepted and PEP 765 is to disallow returnees

return, break, and continue that exit a finally block. That's a lot of terms. So what am I saying? It's that there's the keywords return, break, and continue shouldn't show up in a finally block. And when I first saw this, I'm like, why would I do that anyway? I just don't, I usually put pretty simple stuff in finales and I wouldn't ever think to do a

I might think to do a return or anyway, the, the, the, it's just bad. And the behavior apparently is surprising. So, so they really would hope to not have that in there. So apparently this was rejected once before, but now it's accepted slightly different. There's a, the, I guess there's some cost benefit analysis of the change that was done and it will be better for everybody if we do this. However, because,

because of some backwards compatibility stuff, it will not be a syntax error. It will be a syntax warning. So I guess we'll rely on people running with dash WA or having rougher placate or pilot or something, check this stuff for us. But basically don't do it. Just don't. It's not good. It's not good. Yeah, I can sure see returning it finally.

That makes a lot of sense to me. It's a little, I'm not sure why return is pulled out, but like break and continue and other looping. I can see why that's all right, but yeah, whatever. I mean, it's not hard to work around. Just that. Yeah. So this isn't a big topic. Just, just to be aware, if you're doing something fancy within your finally blocks, pay attention to this. Stop. Stop. Stop. Apparently. Yeah.

All right. Well, we're going to stop with our items, aren't we? Yeah, we are. We've got some extras. We sure do. So exciting. Let me fire some up. So remember our teapot episode? Yes. 418, I'm a teapot. Well, we had our joke about the teapot. And I think the person who created the joke that we covered...

felt that he didn't get enough love or something like that because we pulled up a post somebody had on mastodon blue sky blue sky i think that said hey funny joke person shared it well nikita says important correction uh we i think it's i i created this joke so anyway thank you nikita for um creating this joke it was very funny so i'll link to that to give him a little bit of credit

Next up, Brian. Like a slightly different name. So Nikita reported it. It was a joke by Nikki Tonski, a different person. Oh, different. Okay. All right. Perfect. Well, thanks for the correction.

So I have something really surprising. So check this out. I had a Mac mini M1, the very, very first Apple Silicon Mac that came out, the Mac mini. I got it in 2020. And I remember, I think we talked about this at the time in 2020, I'd already ordered the new MacBook pro, which was still the Intel. Then I saw the Apple Silicon stuff come out and I actually canceled it and like reordered the mini and it was best decision ever.

Well, good decision. And worked out great. But it's just been chilling around here. I've had my Mac Mini M2 Pro that's all maxed out and it's been laying around. I thought, you know, I'm not doing a lot with the other one. But I wanted to set it up so I could do easier recording. It's starting to get a little slow. But you know what? I'll just...

I'll just live with it. I don't really need to buy a new mini. Like I don't need to waste the money just for that. And then for some reason I started, I saw the, that Apple started having refurbished ones that you could buy. And it turns out to not be a very good deal. It's like, Hey, the refurbished one's like five 79. The new one's five 99. And I go, wait, I'll just take the new one. But yeah,

I looked, what would my old 2020 Mac mini trade in for? Well, first of all, how much is a new Mac mini with the M4, 10 core, 10 GPU? Pretty much the same specs, except for the hard drive. Oh, and it's the brand new way, way faster computer. 599, 600 bucks US. Wow. My old mini from five years ago traded for 425. What? So I got a brand new Mac mini M4 for $175. Wow.

I want to point out, anyone else, before any of this stuff changes, you might also want to get a new Mini for $175 if you have a five-year-old one. How awesome is that? Yeah, I think mine's only a couple years. I should check it out. But it might be worth checking out. And I ran it through Geekbench here.

And even against my M2 Pro, which is way faster than my old Mini, this new one that was $175, a lot faster than even the M2 Pro. Single core is like 40% faster. Even multi-core is something like 20% faster for that little bit of money. So, hey, that's just putting it on the radar. Y'all might want to check that out. That's a pretty good trade, in my opinion. Nice.

All right. That's all for my extras. But yeah, I just thought that that was a really surprising thing. I'm like, you know, all right.

Okay. I have a couple extras. I'll trade the mini. A couple extras. Also, I just really love using the mini to record with because it's always silent. It's always silent. Yeah. And they're pretty cheap, even go big. So I just went for a bottom-end one. I think I spent $400 on this or something. Ridiculous. Well, you probably can trade it and get one for like another $20. Yeah, maybe. Maybe.

So I have mentioned before that I'm not a fan of Scheme and Lisp. Oh, gosh. I guess I just want to hit a nerve for at least one person. Philip, and I'm sorry, Philip, I'm not going to try to pronounce your last name, but it looks cool. Lisiak? Something like that? Okay. Laziak? Nice. I'll probably mess it up, but we'll see. Okay. But...

He decided to... And we interacted on the... I think Fostedon or Blue Sky or something. Yeah.

And just kind of, he said, you know, basically, what do you got against it? I'm like, I don't have anything against Scheme really. I just, personally me, I didn't find a lot of use for it. And we talked about it and I actually wrote up this big conversation with him that I need to make into a blog post because I do appreciate that I learned Scheme, I just haven't used it a lot. So, and he said, there's a lot of uses. And I said, I'd love to hear some. And he's like, oh, okay, well then I'm gonna have to write a blog post.

So he wrote, um, uh, my land of scheme in, uh, 2025. So, um, uh, block, we're going to link to a blog post of all the cool stuff that scheme does, uh, lately, at least from his perspective. So that's cool. And then, um, uh,

This is actually really, I really enjoy his writing style. So I really like good long form blog posts, but anyway, good writing style. Thanks, Philip. And he also just recently released another article exposing flaky tests with PyTest rerun failures. And it's a, it's a plugin that I've used a lot too. So cool writing. So keep up the blogs, people like it.

And I'm really sorry if I have offended anybody that likes Scheme or what else? Who else can I offend? Perl writers, C Sharp. I just don't enjoy writing C Sharp and Scheme. It isn't anything against the language. It's just not for me. So anyway.

Alright. Well, I can see why it's tough, Brian. I can see why it's tough. I actually pulled this joke up when I thought of... I can see why it's tough. And I thought of you when I said it. So, question. This is like you being too logical or you may be a tester. When I was four, my sister was two. I'm now 44. How old is my sister? Programmer. Easy. 44 minus four, but minus two from that. That's two years difference, the gap. So, 42. Tester. Tester.

Well, you see, this is a tough one. She might be 42, but she could be 41 or 43 also, since you didn't say when your birthday is and her birthday is. Also, she could be dead. Finally, I thought she was your sister. You might have thought she was your sister, but actually your mom had an affair with another man and a woman who was one. And

And it turns out it's not your sister. So with that, you know, and on and on it goes. Give it away, your real sister. You don't know how old she is. Finally, what if you think your sister is dead, but she actually has become an astronaut on a secret government project and she's been traveling at near light speed. Now her time is going much more slowly. She could actually be younger than 41. You see, it's hard to be a test of reign. Yeah.

Yeah, I like Anthony's answer. Two is half of four. Oh my God. Hey, Anthony, shout out in the audience there. You are absolutely right. And if you go to the YouTube comments, it's duh, she's 22. Then it says, someone else says, a fellow McDonald's graduate, I see. Yeah, that was an easy one.

Oh, follow up. That's a chat GTP answer. Chat GPT answer. Last time she was half your age. Oh my gosh. Okay. Oh, and a nice inside joke there. Anthony making fun of AI since he's pretty much an AI pimp these days, as far as I remember. But anyway, anyway, the comments are pretty funny as well. And then somebody just responds green. Yeah.

Awesome. Well, it's great to have people in the audience to chat with and be part of the show. And Brian, great to be here with you, right? It's good to be with you. Bye.