We're sunsetting PodQuest on 2025-07-28. Thank you for your support!
Export Podcast Subscriptions
cover of episode #423 Traveling the Python Universe

#423 Traveling the Python Universe

2025/3/10
logo of podcast Python Bytes

Python Bytes

AI Deep Dive AI Chapters Transcript
People
B
Brian
Python 开发者和播客主持人,专注于测试和软件开发教育。
M
Michael
帮助医生和高收入专业人士管理财务的金融教育者和播客主持人。
Topics
Michael: 我介绍了 PySQLscribe 这个库,它可以帮助简化 SQL 查询的编写。通过指定数据库方言(例如 MySQL、PostgreSQL、Oracle)和表结构,你可以使用它来构建各种复杂的 SQL 语句,包括 JOIN 和聚合函数。它可以减少编写和调试 SQL 查询所需的时间和精力,尤其对于那些不经常编写 SQL 查询的 Python 开发者来说非常有用。 我个人认为,PySQLscribe 的一个潜在改进方向是自动识别数据库表结构。如果能够通过提供数据库的 CREATE 语句或其他元数据来自动生成表结构信息,那么使用 PySQLscribe 将更加方便快捷。 总的来说,PySQLscribe 是一个有用的工具,可以提高 Python 开发者的工作效率,特别是对于那些需要与数据库交互的项目。 Brian: 我分享了两个关于 Python 生态系统和趋势的资源。第一个是一个 PyPI 包依赖关系的可视化工具,它展示了 Python 包之间的复杂依赖关系,并引发了关于大型数据集处理和数据可视化方法的讨论。这对于理解 Python 包的生态系统和依赖关系非常有帮助。 第二个资源是关于 Hacker News 上 Python、Rust 和 C++ 编程语言职位需求的分析。分析显示,虽然 Python 的招聘需求有所下降,但求职者数量增长迅速,这表明 Python 职位仍然很抢手。此外,分析还讨论了内存安全语言(如 Rust)的兴起及其对 C++ 等传统语言的影响。 总的来说,这两个资源都提供了关于 Python 生态系统和趋势的宝贵见解,有助于开发者更好地理解 Python 的发展方向和未来趋势。

Deep Dive

Chapters
This chapter introduces PySQLscribe, a Python library that simplifies the process of building SQL queries. It allows users to define database dialects, tables, and columns, then construct queries using a builder object, generating SQL statements automatically. The discussion also includes potential extensions like parsing create scripts for automated table structure recognition.
  • PySQLscribe simplifies SQL query construction in Python.
  • Supports various database dialects.
  • Allows defining tables and columns for query building.
  • Potential for extension to parse database create scripts for automated table structure recognition.

Shownotes Transcript

Translations:
中文

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

Talk python.fm. So lots of great courses there. And our patron supporters, of course, thank you. And for people that like to get ahold of us that 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 pythonbyst.fm not and and there's also in the show notes, there's links to our blue sky and

mastodon links and you can also sign up um at pythonbytes.fm you can go to live and uh to see when the next live show is going to go on or you can shine sign up for the newsletter and get the everything we talked about sent directly to your inbox which is cool yeah they can crush that bell on uh youtube too oh yeah subscribing on youtube that would be great um yeah yeah so

Speaking of subscribing or scribing, what are we talking about first? Well, how's your SQL 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've 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? 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 deep down when it docs 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. 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. Each database has its own dialect

Alright, 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 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 table name, here are its columns, and so on. And then you can just say, "Create a little builder," and say, "builder.select this column, that column."

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. 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

So for example, here's a MySQL table. So you don't have to specify the dialect because it's a MySQL table. 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 iCloud.

on this thing and then build and it'll write the join statement for you, which is pretty neat. You can also do, like I said, functions. 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? And a group by type of thing.

So you could just go and write that in terms of the SQL scribe, the PI SQL scribe, and then it will actually generate all that for you. So that's pretty neat. And finally, you can combine them if you have one builder inside of another builder type of thing.

it'll join. It's a more complicated thing. So the more you do with SQL, probably the more helpful this is. If you're just doing a little simple select and where statements, maybe not that helpful. But that is my first item. I think it might help some folks. Yeah, I guess you're probably the right person to ask, but I was just curious about the use case. So like, what...

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, 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. Okay. Because it does that, right? I think it's...

I would like this thing to help me write the queries because I'm, 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, but that's probably a join. How do I do that again? And so on. Okay. Yeah, it was actually, I was just thinking about putting an application together and I was like, it's pretty lightweight. I don't really want an ORM.

So I was going to do raw SQL, but then I, 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, the responses as parameterized queries in your Python code and don't revisit it again until you might need to change the query, you know, a sufficiently complicated way that you can't just like type another column or something. You know what I mean? Yeah. Okay. Yeah. Interesting. Cool. One addition that I added here added, um,

Sort of. An idea I added, I guess, as I was getting ready for this, I thought, you know what? 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 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 in 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 parsa 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 you like the idea or not but i think there's some cool ways to expand this cool nice yeah all right over you

Well, I'm going to add, I'm going to look at a map of Python. So I ran across this article. It's kind of cool. So the idea is around looking at PyPI's got tons of packages there, but there's a lot of dependencies between them and visualizing kind of how Python

What would it look like if we visualize 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 to zoom in. And I couldn't figure out what the spacing meant. But anyway, why I'm... Okay, so since I don't really know what this is doing, 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's copies in BigQuery so that you can query that instead of querying PyPI all the time, which is something that I've done with the Python or PyTest plugin list as well.

But then there's some discussions. Well, there's some junk in there. There's packages that don't have source code listed or 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 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, there's a link that said, oh, yeah, by the way, there's a better UI for this. Like, OK, let's take a look at that. And this is just cool. It's the spaceship.

i don't know spaceship operating manual um wow 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 is like hubble yeah so look look at this if we move forward and back oops

Oops. Let's see. W. Let's see if we can get this to go. This is great. So for people listening, I'm zooming in, and it's like you're going through a star field. And these are Python dependencies that we're going around in. It's a fun, I don't know, video game, video visualization thing. I'm going to play with it. I haven't seen this before. I'm going to play with this later. Thanks. You 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. So even Reproduction Guide said there's the SQL query. So if you'd like to do some BigQuery stuff for around PyPI, there's an example. There's 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. 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. 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, we really knew software should be written 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 that we'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 Ociak 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++. 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. But the Python one is trending downward faster than the other two. So what does that mean? Like 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 industry.

They're all going up a little bit generally, but Python is going up way faster. So if you were 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++, Rust, and Python, I'm like, oh, no. But it looks like if you just look 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. Yeah.

If that's individuals trying to find a job who don't have a job that you have or want. 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 a Python? Oh, right. So the fact that that's going down means fewer people are not in a job that they want. Right. They're like, they're employed. That's a good thing. 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 person.

they're not easily filling the jobs. 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 can say that. - That's more optimistic then. - Yeah, I think it's optimistic on both graphs. It just depends how you read it. - Yeah. - Yeah. I mean, it's hacker news, right? But it's still an interesting angle, you know? - Yeah.

My, I guess my take on the C++ versus other things or the demise of C++ or whatever, I don't think we're going to see a demise of C++. 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

And 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 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 recently.

there's some really interesting conversations about like, if you're gonna, you know, they just did, God, 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, an array use after free, right? Like the whole category of like things that happen because you're in a memory unsafe language. Um,

Microsoft was something like in the 60 to 70% of all security problems with the software has to do with memory issues. Oh, yeah. 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? Yeah. And so if you're choosing new software,

You're choosing new projects to start from scratch and you're picking some systems level language like C, C++, Rust, whatever. And you don't choose a memory safe language. You're basically choosing to have, you know, two and a half times as many vulnerabilities in your software. And I think that's what the 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. And you can do stuff, you can do stuff in say C++, right? Writing these 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, 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 actually,

access system is really easy to put together in C++. And I don't know how to do it somewhere else. I mean, I'm sure there's ways. And we're always going to have software talk to hardware. So unless it gets really easy to do that in another language, we'll have C++. MARK MANDEL: Yeah, or someone builds a little layer

- Well, it probably already is. We just don't know. I don't know about it. - Yeah, yeah, yeah. I don't either. 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.

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 more. I mean, what am I using now? Not Google, something else, some Google alternative. And but there's help there and it's pretty good. So linking to Trey Hunter's article, features of Python's help function and help is is

is really pretty good with Python as 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 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 a line feed code look like? And what's a, you know, all of those, those are in 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, there's a lot of interesting information in here. And I think I remember looking at a,

I don't know, like literals and some of the some of the other things in here. Namespaces is a good one. Just probably a really good discussion around none.

and in numbers and objects. And there's a lot of great information around 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 a 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 let's 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 and dot from underscore? And I knew that the old parser, that would probably be the case, right? Yeah. Because it just looks for the word from. But with the new, like,

peg parser forward looking thing. I thought, oh, it's going to 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. Yeah. You don't really have to memorize them though, because Python will not let you like, it's just, it's going to be like, Hey, that's a keyword. Yeah. Don't 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, I got one. Quick, quick, quick. So last week I mentioned that Grinion, Grinion's going strong. How many stars? We have 3,200. This is the rust based one. Oh yeah. That is based, that basically is like a handy wrapper around Hyper, right? Which Hyper is a rust wrapper.

HTTP engine and that has 15,000 stars. So you're quite popular, 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, Outroll's patch release 201, changes since 2.0.0, fixed a regression bug preventing any I.O. to thread .run sync to work. And FastAPI makes heavy use of any I.O. So that seems like that was probably the problem.

gave 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, but because since I said it didn't work, 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 I had to pull up I was looking for like I had a big large large set of packages that work together internal thing and something was using greenlit and I'm like what is what is using greenlit and

And I pulled out pip-dep-tree. Oh, yeah. I love pip-dep-tree 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 all you have installed and what dependencies there are. And so I easily searched through that 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. Yeah.

I just needed to update my playwright and we were good to go. Excellent. Yeah, 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 haven't used it that much lately, but 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 the 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. Cause it's like, I don't think I'm using it anymore, but could break stuff and let's just, what's it hurting in there? You know, like it can really be, can become real easy for that to become stale. So, you know, you get a little, a little better look of, of it from, from pip dev tree maybe. Anyway, yeah.

How about a joke? Sounds good. I brought a series of battling conspiracy theories to do with technology here. That 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. 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. Back at you. I think right back at you. And then the subtitle, or 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. Was the geologist inspired by Amazon's just walk out technology? Yeah.

Remember, do you know the story behind that? You know the Amazon, like walk in, pick up wherever you want, you register your card, pick up wherever you want, and you walk out and they just charge you? Yeah. I'm pretty sure that...

I don't have any good sources off the top of 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, and someday maybe it was supposed to eventually become powered by AI and video recognition, but it was,

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. 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. Like, so a lot of people are using AI for stuff and I'm using it for some things as well. But the, but for some things companies are doing, like they're putting together lists of tasks and having like it,

if they were going to hire a person to do this, a person should be able to do this task and this is the output they should get. Then putting those tests to AI agents and just other ways to use AI and rating them that way.

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 it 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. Yeah, you got a grade on a good curve there. Yeah.

There you go. 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. Yeah. What a boring job. Or maybe interesting. I don't know. Watching people shop.

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.