Python Bytes - #423 Traveling the Python Universe

Episode Date: March 10, 2025

Topics covered in this episode: pysqlscribe A map of Python Rust, C++, and Python trends in jobs on Hacker News (February 2025) The features of Python's help() function Extras Joke Watch on YouTub...e About the show Sponsored by us! Support our work through: Our courses at Talk Python Training The Complete pytest Course Patreon Supporters Connect with the hosts Michael: @mkennedy@fosstodon.org / @mkennedy.codes (bsky) Brian: @brianokken@fosstodon.org / @brianokken.bsky.social Show: @pythonbytes@fosstodon.org / @pythonbytes.fm (bsky) Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too. Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it. Michael #1: pysqlscribe A Python library intended to make building SQL queries in your code a bit easier. A Query object can be constructed using the QueryRegistry's get_builder featuring a dialect (e.g; "mysql", "postgres", "oracle"). Brian #2: A map of Python Cool visualization of dependencies in PyPI packages Even cooler visualization (linked from main article) Michael #3: Rust, C++, and Python trends in jobs on Hacker News (February 2025) Interesting supply and demand comparisons from at least on source. Brian #4: The features of Python's help() function Trey Hunner Don’t forget how useful and cool help() is. Extras Michael: Granian works with FastAPI again Joke: Computer engineer vs. Geologist

Transcript
Discussion (0)
Starting point is 00:00:00 Hello and welcome to Python Bytes where we deliver Python news and headlines directly to your earbuds. This is episode 423 recorded March 10, 2025 and I am Brian Ocken. And I'm Michael Kennedy. And thanks everybody again for supporting us through training courses at pythontest.com and at talkpython.fm. So lots of great courses there and our patrons supporters, of course. Thank you. And for people that'd like to get ahold of us,
Starting point is 00:00:30 we'd love to get here. If you've got a suggestion for the show or have a question about it or correction, you can reach the show at pythonbys.fm. And there's also in the show notes, there's links to our blue Sky and Mastodon links. And you can also sign up at pythonbytes.fm. You can go to live to see when the next live show
Starting point is 00:00:55 is going to go on. Or you can sign up for the newsletter and get everything we talked about sent directly to your inbox, which is cool. Yeah, and they can crush that bell on YouTube too. Oh yeah, subscribing on YouTube, that would be great. Yeah. So speaking of subscribing or scribing,
Starting point is 00:01:15 what are we talking about first? Well, how's your sequel game, Brian? A little weak, actually. Yeah, mine's a little weak as well. It's atrophied a bit. You know, I've got its table and I got got another table and I want to do a join on that table and then maybe I want to use an aggregation function. How do I do that again?
Starting point is 00:01:33 Well, there's a lot of cool tools and libraries around there to solve that. For example, you can use SQL Alchemy or SQL Model and then you just talk in Python terms and classes and stuff. And then somehow, magically magically deep down when it talks to the database, it'll do that kind of stuff for you. You still kind of got to know the queries, so it's not perfect, but it does perfectly solve it for you. But I want to introduce everyone to a new tool called PySQL scribe. And the idea here is similar to that, except for you use it for real SQL.
Starting point is 00:02:05 So for example, if you want to know how to do one of these joins, or you want to get some support doing that, and you're not already using SQL Alchemy, it's not reasonable to say, well let me re-implement everything I'm doing in SQL Alchemy, so I can ask it a question to get a simple SQL statement that I just want to use outside of SQL Alchemy. So that's kind of what this is. So you can take this thing, and you teach it about different things, which database you're using. Because even though SQL is a general query language, it does not generally work against any database.
Starting point is 00:02:38 Each database has its own dialect. So the way you say, for example, specify parameters for MySQL is different than the way you do for Microsoft SQL Server. And while they are similar, they're not the same. So what you do is with this is you say, I'm working with this particular database. And then you say, you give it information about your tables, right? So here's a, a table name here over its columns and so on. And then you can just say create a little builder and say builder dot select this column, that column,
Starting point is 00:03:06 from this table, build. And what it builds is it outputs a select or a SQL statement of some sort. So in this case, select the various columns from the table. Cool, right? Yeah. Yeah. But you can do more than that.
Starting point is 00:03:21 You can, let's see, you can create your own class by creating a class that is decorated. And then it will know that basically you can create either your own queries or you can create your own dialect. So for example, here's a MySQL table. So you don't have to specify the dialect because it's a MySQL table.
Starting point is 00:03:41 It knows the dialect. And if you go further down here, you can see it understands more complicated things like join. Like first I want to select this thing, then I want to join on that table on this thing, and then build and it'll write the join statement for you. Just pretty neat. You can also do, like I said, functions.
Starting point is 00:04:00 Let me scroll down a tad to that. So for example, if you wanted to write something that did, you know, uppercase in the select statement or max of some value out of there, right, in a group by type of thing. So you could just go and write that in terms of the SQL scribe, the PySQL scribe, and then it will actually generate all that for you.
Starting point is 00:04:22 So that's pretty neat. And finally, you can combine them if you have one builder inside of another builder type of thing. And it'll join into more complicated things. So the more you do with SQL, probably the more helpful this is. If you're just doing a simple select and where statements, maybe not that helpful.
Starting point is 00:04:40 But that is my first item. I think it might help some folks. Yeah, I guess you're probably the wrong person to ask, but I was just curious about the use case. So like, for instance, I guess if you had an application that the user could select which database they're connecting to, and then you could create the different features based on that and just, I guess. Yeah, I don't think it's operational in a sense. I think it's more, because if you're doing it operationally, just use ORM.
Starting point is 00:05:09 Okay. Because it does that, right? I think it's, I would like this thing to help me write the queries because I'm, Okay, and then you just. Sometimes I forget, like if you're doing data science, you might be connecting to different data sources. You might be going, oh, I want to ask this question,
Starting point is 00:05:24 but oh, that's probably a join. How do I do that again? And so on. OK. Yeah, I was actually just thinking about putting an application together. And I was like, it's pretty lightweight. I don't really want a norm.
Starting point is 00:05:34 So I was going to do raw SQL. But then I. Yeah, so what you might do is you might run this one. You might give it your specification, run it one time, and then hard code the responses as parameterized queries in your Python code and don't revisit it again until you might need to change the query in a sufficiently complicated way that you can't just type another column or something, you know what I mean? Yeah, interesting.
Starting point is 00:05:59 One addition that I added here, added, sort of, an idea I added, I guess, is I just, as getting ready for this, I just thought, you know what, this is like typing in the names of the columns and the available tables seems like that should be automated. So I don't know if Daniel, the guy who created it, has any interest in this, but I said, hey, wouldn't it be cool if you could give it
Starting point is 00:06:22 a create script, you know, you can go to your database and say, create an entire create script for the entire database with all the columns and the relationships and indexes and all that kind of stuff. You could just point it at that. And then it could generate all the tables as an end thing you pull in by table name. And then it just automatically knows the structure of everything of all your tables. Right? So I said, hey, maybe you can make it parser SQL data, create data definition, language, create script sort of thing. So I gave a little example of something you might be able to do there. So who knows if it comes around, if he likes the idea or not, but I think there's some cool ways to expand this. Cool. Nice. Yeah. All right. Over to you. Well, I'm going to add, I'm going to look at a map of Python. So I ran across this article.
Starting point is 00:07:12 It's kind of cool. So the idea is around looking at, PyPI's got tons of packages there, but they, there's a lot of dependencies between them and visualizing what it would look like if we visualized all of this. So there's a couple of visualizations here. And I actually got a little lost in trying to interpret this, but it's pretty dots. But you can zoom in a little bit on some of these. The scroll wheel works on this, does zoom in. And I'm not, I couldn't figure out what the spacing meant. But anyway, I, why I'm, okay, so since I don't really know what this is doing,
Starting point is 00:07:55 why am I covering it? One of the things I thought was great was it was just sort of a discussion around dealing with large data. And the data set of PyPI is a pretty big data set. There is big, there's copies in BigQuery so that you can query that instead of, instead of querying PyPI all the time,
Starting point is 00:08:17 which is something that I've done with the Python or PyTest plugin list as well. But the, it's, but then there's some discussions. Well, there's some junk in there. There's packages that don't have source code listed or there's other things that make them really not, they're not really open source. They're just utilizing PyPI or something. Sometimes companies do that. Anyway, so there's some discussion around filtering that, which is an interesting discussion. And then a little bit of discussion about deciding what graphing mechanism to use and how to visualize it. So I just really
Starting point is 00:08:56 appreciated the discussion. So if you're into visualizing data, I think this might be an interesting thing. Plus it's just a really fun visualization. And then at the end, uh, there's a link that said, Oh yeah, by the way, there's a better UI for this. I'm like, Oh, okay. Let's take a look at that. And this is just cool. It's the spaceship, uh, I don't know, spaceship operating menu. Um, so this is like the galaxy of Python. And let's see if we have W and S for forward and back. The first one was kind of like, I don't know, old school maps. It was really cool. But old school maps and like, you know, the days of like sailing and exploring and this
Starting point is 00:09:32 is like Hubble. Yeah. So look, look at this. We move forward and back. Oops. Let's see. W, see if we can get this to go. This is great.
Starting point is 00:09:41 So for people listening, I'm zooming in and it's like you're going through a starfield and these are these are Python dependencies that we're going around in. It's just it's a fun, I don't know, video game video visualization thing. So I'm going to play with I haven't seen this before. I'm going to play this later. Thanks. Just wasted like a half an hour of my day. You're welcome. Yeah. And so this is all on GitHub also. So if you want to take a look at how he did the filtering, and I'm linked to this because I'm going to take a look at how he's doing.
Starting point is 00:10:14 So even Reproduction Guide said there's the SQL query. So if you'd like to do some BigQuery stuff for around PyPI, here's an example. There's a process JSON, so how he's using the filters and stuff, and then converting it to a graph. So some great, nice open source, or nice examples of how to do data and visualization and stuff. So.
Starting point is 00:10:38 Yeah, I love it. It's beautiful. Very, very cool. You'll have to follow the links to explore it. Yeah, and play with the space one. That's fun. Yeah, the space one is the one I was thinking of. Awesome.
Starting point is 00:10:51 Want to talk Rust, C++, and Python? I heard Bjorn was saying that C++ is under attack, Brian. How do you feel about that? It's under attack. I think so. I heard people say that. I've heard a lot of it. We really knew software should be written
Starting point is 00:11:06 in a memory safe language, and that doesn't work with C++. Anyway, that's not the point of this. Yeah, I'll have a comment later though, I'll have to add, so yeah. Okay, I'm here for it, I'm here for it. But that's not what it's about. This is by Martin Otsiak,
Starting point is 00:11:21 and it is Rust, C++, and Python trends in jobs on Hacker News. Interesting. Yeah. So there's, I don't know how he found this data, but somehow, hey look, maybe just conversations on Hacker News might serve as a proxy for programming language job demand. So there's two questions, you know, ask Hacker News who is hiring and ask Hacker News who wants to be hired for February 2025. And then there's graphs of how many times those appear for Python, Rust and C++.
Starting point is 00:11:55 So if you look at it and this data actually goes back, I don't know what, I guess it's as of February, but this goes all the way back to 2021. So this is pretty long term data. Five years, four years. And so if you look at Python, it's trending downward pretty sharply. So are C++ and Rust, although they're starting to take up, I guess they're all a little bit starting to take up here at the very end.
Starting point is 00:12:20 But the Python one is trending downward faster than the other two. So what does that mean? That people more and more at a higher rate of speed, people are not asking who is hiring in a particular language, right? Now if you look at the other one, the inverse, who wants to be hired? Like, hey, we need people, we need people in this.
Starting point is 00:12:39 They're all going up a little bit generally, but Python is going up way faster. So fewer people asking to be hired, more and more people are going, where do I find Python people? It looks like there's more demand for Python people over time. There's still more demand for C++ and more demand for Rust people, but at a slower rate of speed. Interesting, huh? Yeah. And I was like totally depressed for a while looking at this graph. Because of the sharp downward trend of all programmers, at least for C++ for us on Python, I'm like,
Starting point is 00:13:12 oh no. But it looks like if we just look at it from 2021 to now, it's a downward slope. But if it's kind of- Which one though? The who's hiring or who wants to be hired? Well, I guess I don't get it. Like the who's hiring. If that's individuals trying to find a job who don't have a job they either have or want. Oh, okay. Right? They don't have a job at all or they have a job that they don't want. They want one in that technology. Okay. Who's trying to hire Python? Oh, right. Okay. So the fact that that's going down means fewer people
Starting point is 00:13:46 are not in a job that they want, right? They're like, they're employed. And they're employed kind of happily. So the fact that that goes down is good. And then you look at the next one, I don't know if this is good or bad, but there's fewer people per, they're not easily filling the jobs.
Starting point is 00:13:58 It's getting harder and harder to fill the Python jobs at a faster rate than it is for the others. That means basically there's more employer demand, I'm pretty sure. That makes sense. Per candidate, I guess, if you consider that. That's more optimistic then. Yeah, I think it's optimistic on both graphs. It just depends how you read it. Yeah.
Starting point is 00:14:16 Yeah. I mean, it's hacker news, right? But it's still an interesting angle, you know? Yeah. I guess my take on the C++ versus other things are the demise of C++ or whatever. I don't think we're going to see a demise of C++, but the, but there's a lot of stuff. It is difficult to learn. No, no doubt about it. Rust, I think is difficult to learn too, but it's, I think more manageable for people to come up to speed on a small project with Rust than Python. But maybe, maybe I'm wrong about that. But I think the, we need to do, I think one of the gains of Rust is we need a way, it's around Python, is we have this great Python project, but there's a little bit of it here that needs to be sped up. What do we do? Do
Starting point is 00:15:04 we jump into C++ that we don't know about or Rust that we don't know about? And I think people are choosing Rust. So anyway, that's my take on that. Yeah. I listened to a couple of cybersecurity, computer security podcasts, and there's some really interesting conversations about like, if you're gonna, you know, they just did one of them just did an analysis and said, I think 70% You know, they just did, one of them just did an analysis and said, I think 70% of all, 70 or 80% of all security problems with iOS were memory, memory corruption, memory failure issues, right? Off by one on an array, use after free, right? Like the whole category of like things that happen because you're in a memory unsafe language. Microsoft was something like in the 60 to 70% of all security problems with the software
Starting point is 00:15:49 has to do with memory issues. And he goes, you can just go through them like one after another and they're all, they've all got that flavor, if not the exact same numbers, you know what I mean? And so if you're choosing new, you're choosing new projects to start from scratch and you're picking some systems level language
Starting point is 00:16:07 like C, C++, Rust, whatever, and you don't choose a memory safe language, you're basically choosing to have two and a half times as many vulnerabilities in your software. I think that's what my language is under attack feel is. It's like, yeah, but that fact is still a fact that I'm sorry, but it is, you know? Yeah.
Starting point is 00:16:30 And you can do stuff, you can do stuff in say C++, right? Right? You can use like smart pointers and things that will automatically free them and so on, but probably not for C. But it's still present, you know? There's still S print F that was, you know, print F that was wrong or whatever. Yeah. And I guess I've spent so much of my life in the low level world of like device drivers and stuff that that's one of the beautiful things about C++ is a memory mapped hardware access system is really easy to put together in C++.
Starting point is 00:16:59 And I don't know how to do it somewhere else. I mean, I'm sure there's ways, but so and we're always going to have software talk to hardware. So in, unless it gets really easy to do that in another language, we'll have C++. Yeah. Or someone builds a little layer. We probably already is. We just don't know. I don't know. Yeah. Yeah. Yeah. I don't either. I don't live. I don't live in that world these days. Anyway, that's pretty interesting stuff. Yeah. Yeah. All right, over to you for your final thing. Well, so there is help, and it is only a keyword away.
Starting point is 00:17:30 So I, you know, occasionally I forget about this. So it's so tempting if you have a question about the world of Python or anything is to just Google something or, I'm using, what am I using now? Not Google, something else, some Google alternative. But there's help there and it's pretty good. So linking to Trey Hunter's article,
Starting point is 00:17:53 features of Python's help function. And help is really pretty good with Python and it's part of built in, I don't know if it was built in from the language at the beginning, but it's been there for as long as I've been using it. But if you say help, you can give it a string and you can give it a you can say help on a function, you can say help on a module, symbols, keywords, topics, objects, and there's
Starting point is 00:18:15 useful stuff that often comes out. So this article is talking through some of the things you can do. One of the things that I like is looking at meta help, the meta help is pretty interesting, you can have basically there's a, if you say help and give it the quote topics, you get a list of available topics and you've got stuff like strings. I looked up strings. I'm like, well, I don't know how to use strings, but I looked it up. And one of the things that strings has is all these scape codes. So like what is a, what does the line feed code look like?
Starting point is 00:18:45 And what's a, you know, all of those, those are in the- Yeah, like the backslash T, the backslash N, but there's gotta be some that I don't know. Yeah, there's a bunch of others. And so there's a lot of interesting information in here. And I think I remember looking at, I don't know, like literals and some of the other things in here. Namespaces is a good one. Just probably a really good discussion around none and numbers and objects.
Starting point is 00:19:13 And there's a lot of great information around Python just available with the help utility. So here we go. Help symbols. So here's all the symbols of Python. So if you're curious what all the keywords, oh yeah, you just have list all the keywords there. There's really not that many Python keywords. Wow, that's pretty interesting. Anyway, yeah, don't forget help. And those keywords are things that you can't use as variables or functions or say symbols more broadly in Python. I just realized that from this PySQL scribe, I was like, why do you have to say select thing then dot from underscore.
Starting point is 00:19:50 And I knew that the old parser, that would probably be the case, right? Because it just looks for the word from. But with the new like peg parser forward looking thing, I thought, oh, it's gonna be smart enough to know that this is being used in an expression and not keyword. No, so you can say help symbols and keywords and those are the things you can't name symbols at all.
Starting point is 00:20:09 Yeah, you don't really have to memorize them though because Python will not let you. Like it's just a... It's gonna be like, hey, that's a keyword. Yeah, they'll do that. Can't do that. Yeah, for sure. For sure. All right. Extras, what do you think? Yeah, extras would be great. Do you got any? Got any? Yeah, yeah, I got one. Quick, quick, quick.
Starting point is 00:20:26 So last week, I mentioned that Grandian, Grandian's going strong. How many stars? 3,200. This is the Rust-based one that is based, that basically is like a handy wrapper around Hyper, right, which Hyper is a Rust HTTP engine, and that has 15,000 stars, so quite popular.
Starting point is 00:20:49 But that they released 2.0, and that meant fast API and probably a lot of starlet stuff as well. Just stopped working categorically. Whoops. Well, the next day out rolls, patch release 201, changes since 200 zero fixed a regression bug preventing any IO to thread dot run sync to work and fast API makes heavy use of any IO.
Starting point is 00:21:16 Yeah. So that seems like that was probably the problem. Give it another go and all the fast API things are happy again. Cool. So just as a follow up from last week, really. Yeah. I wouldn't point it out that normally, because since I said it didn't work,
Starting point is 00:21:28 I'll put it back on the checkbox if now it works again. All right, that's all I got. Quick and easy. I got no extras, although it just reminded me, I guess I don't have a page for this, but looking at dependencies, I had to pull up, I was looking like I had a big, large set of packages that work together, internal thing, and something was using Greenlit.
Starting point is 00:21:51 And I'm like, what is using Greenlit? And I pulled out pip-deptree. So I love pip-deptree to quickly take a look at what, if you run that, if you just pip install it and run it, and it'll show you in a tree form, what are all you have installed and what dependencies there are? And so I searched, easily searched through that
Starting point is 00:22:14 and found out that Playwright was using Greenlit. And I'm like, oh, well, I'll trust them that they have a good reason to use it. So I just needed to update my Playwright and we were good to go. Excellent. Yeah, that's I've used that a lot. It's really nice. I use the UV pip compile thing, which now embeds that information into the requirements.txt file, which is nice as well. Oh yeah. Okay. Yeah. Yeah. So I don't, I haven't used it that much lately,
Starting point is 00:22:41 but yeah, if you're in any project that doesn't have one of those generated files, then it's. And another problem you can run into with just having it generate this stuff is, I don't know about you, but when you add stuff to your requirements file, it'd be that pyproject.toml or requirements.txt equivalent or whatever, it's easy to put stuff in there and then not take it out because it's like, I don't think I've used it anymore,
Starting point is 00:23:03 but could break stuff and let's just what's it hurting in there you know like it can really become real easy for that to become stale so you know you get a little little better look of a bit from from pip-dep tree maybe anyway how about a joke? It sounds good. I brought a series of battling conspiracy theories to do with technology here that sounds sounds fun, right? Yeah. So here's a flat earther. I'm all here for making fun of flat earthers. I'm a computer engineer, and I affirm that the Earth is flat.
Starting point is 00:23:35 Apparently, John Davis, the secretary of the Flat Earth Society, you are not alone, Brian. Just because no one else around you thinks the Earth is flat, that doesn't mean there's not a whole hive of people on the internet. All over the globe. All over the globe. So, what is the response? Okay. I'm a geologist and I say that computers work because there are very small people inside doing all the work. Yeah. Right back at you. I think right back at you. And then the subtitle, or if if this is not but if it weren't XKCD the hover whatever that is says this earth is flat versus computers work because there are very small people inside doing all the work
Starting point is 00:24:14 Was the geologist inspired by Amazon's just walk out technology? You know remember do you know the story behind that you know? The the Amazon like walk in pick up whatever you want You register your card pick up or whatever you want you walk out, and they just charge you yeah I'm pretty sure that I don't have any good sources off the top my head right now, but That that was actually instead of being super smart AI Which is what it was billed as there were just people in Countries where it was cheap enough just paid to sit there and watch a camera and just like mark down what you got. And then like,
Starting point is 00:24:51 and someday maybe it was supposed to eventually become powered by AI and video recognition. But the working versions were just people watching you on camera and marking it down as you picked up and put down stuff. Yeah, interesting. Okay. Anyway, I think that's the reference there. That is funny. There was a, somebody posted the other day about some studies that people are doing. So a lot of people are using AI for stuff
Starting point is 00:25:16 and I'm using it for some things as well. But for some things, companies are doing, they're putting together lists of tasks and having, if they were gonna hire a person to do this, a person should be able to do this task, and this is the output they should get. And then putting those tests to AI agents and just other ways to use AI and rating them that way.
Starting point is 00:25:43 And if you do that and have domain experts come up with these tests, like AI is not doing well. But one of the results was about like 16% correct on a lot of these. And the comment was, while impressive, and then went on and I'm like, while impressive, that's just not, I've never got a 16% score in school and had somebody say, wow, that's impressive. But you need to just- Yeah, you got a grade on a good curve there. There you go.
Starting point is 00:26:12 Business insider. Oh, go away cookies. Amazon's Just Walk Out technology relies on hundreds of workers in India watching you shop. That is ridiculous. Yeah, I thought it was RFID or something like that. No, it's magic. It's magic.
Starting point is 00:26:30 Yeah, what a boring job or maybe interesting. I don't know, watching people shop. Yeah, maybe. Anyway, all right. Well, good episode as usual. Good to talk with you. Thanks everybody for tuning in and we'll see you next week. Yeah, thanks, bye.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.