Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 387, recorded June 12th.
And I'm Brian Hawken.
And I'm Michael Kennedy.
This episode is sponsored by Scout APM.
Listen to their segment later in the show.
Connect with your hosts, as always, through Fostadon, at Adam Kennedy, at Brian Hawken, and at Python Bytes.
We'd love to hear from you.
Send in those topics, too.
You can also, there's a contact list on pythonbytes.fm.
You can send things that way, too.
And if you'd like to join the show while we're recording, like some of the people right now,
you can join us on YouTube at pythonbytes.fm/live to be part of the audience.
It's usually Tuesdays at 10 a.m. Pacific time.
And you can also use that to find the link to catch older episodes as well.
And finally, before we get started, if you'd like to have all these topics and the links to everything we talk about sent directly to your inbox,
you can go to pythonbytes.fm and become one of our friends of the show and join that list.
And we'll send those emails to you every week.
Super useful.
A lot of people are signing up to them.
Brian, really quickly, before we jump into the topics, you mentioned Fostadon.
I got a comment on YouTube, I suppose, is the right place to, where it came from.
Somebody said, this guy, me, has gone completely crazy because he joined Mastodon.
Then he joined invite-only Mastodon because Fostadon went to invite-only.
I'm like, but you can join any, there's thousands of servers, join any one you want.
So you don't have to be on Fostadon directly to talk with us.
It's just the same, you know, most people I talk to are not on Fostadon.
If you want an invite to that private server or invite-only server, which I think that's just trying to limit the scope for the admins and the cost of it and stuff,
happy to send you on, but yeah, just any old Mastodon will do.
It doesn't have to be Fostadon in particular.
Nope, doesn't have to be.
Yeah.
It's not Slack, it's not Discord, it's something else.
It's the Fediverse.
But if you really want to get into Fostadon, go into the contact form on our site and send us an email and one of us will send you an invite.
Exactly.
Well, how should we start the show, Michael?
Let's herald in a new era of SQL interactions, shall we?
With the data herald.
So this comes just under the organization data herald.
And the idea is you have a SQL database like Postgres or Microsoft SQL Server or whatever, but you are not, either you don't have SQL skills or you don't want to bother your SQL skills.
This is kind of like for me with regular expressions, right?
Like I can do regular expressions, but I will take a lot of steps to not actually do regular expressions.
You know what I mean?
So this is like that for SQL.
It's a natural language to SQL engine built for enterprise level question and answering on top of relational data.
So maybe you've got a database with a bunch of analytics, a bunch of customers, whatever, contacts for like a CRM type thing.
And you want to let your somewhat technical people just talk to the thing instead of making them learn SQL or use some kind of BI tool.
So you just put this thing on top of you.
You're like, tell me all, you know, how much sales did we get from the Philippines last month?
Something like that.
Right.
Which you could write that as a SQL expression, but you don't have to.
Yeah.
So some of the features are you can allow business users to get insights into data warehouses without bothering the data analyst.
You can enable Q&A chat on top of production databases inside your SaaS application.
That one sounds a little risky, but, you know, maybe internally it's fine.
You got like a self-hosted one or something like that.
Or you could create a chat GPD plugin for your proprietary data even.
Pretty interesting stuff, right?
This is super cool.
Yeah.
I haven't tried it yet.
It's half Python, half JavaScript, 0.3% Docker.
But the 0.3% Docker comes from the fact that if you want to just run it locally, you can just Docker compose up basically.
So they actually have that all put together in a script, but you just Docker run off it goes.
Yeah.
So it's made up of a bunch of different things, an engine, some enterprise rules like permissions and stuff, an admin console.
And interestingly, one final thing to throw out here before we move on is a Slack bot.
So you can add the data herald for your database to your Slack channel and then talk to it as part of your Slack conversation.
What's the deal with this?
It's like, I don't know.
Let's just ask the data herald, you know, and go and send it a message.
And I think that's actually pretty interesting.
I think it's, yeah, it's funny.
It's interesting and kind of funny.
I kind of forgot that a lot of people are still using Slack.
Are you slacking off?
You're not paying attention anymore, right?
I'm slacking off.
Yes.
I still have a Slack.
No.
Yeah.
I have a Slack channel for the course and the book, but it doesn't give a lot of activity.
So.
Yeah.
I'm always torn about these things.
I want to set up something like that.
But Discord seems to have a little more traction for public places like that.
The Slack pricing has gotten really weird.
Yeah.
It's for free on open source stuff and big projects.
It's like, it's got a 90 day limit on it and it throws stuff away, which is a problem.
So.
Yeah, exactly.
I want to set up rocket.chat, which is pretty awesome.
It's like a self hosted or you can buy their hosting, but it's like open source, a lot nicer,
white label, et cetera, et cetera, et cetera.
The only thing is like, if you want to get people to come in and use it and they do,
do they want to have like another app open and remember to go to another place.
I think that's the challenge with Discord and Slack.
It's like, well, I already have that open.
So now I get notifications for that versus here's one more thing to run.
But yeah, this is something I'm thinking about.
It could be fun.
I switched the pytest course recently from Teachable to Podia and Podia has a community
aspect where you can ask questions and answers and stuff like that.
I haven't turned it on yet, but I'm planning on doing that soon just because it solves that
extra login problem.
They already have a login to get to the course.
Right, exactly.
And I can put it right in there.
So anyway.
Cool.
Maybe someday.
All right.
Well, Data Herald, check it out, people.
If you want to talk to your SQL.
Talk to your SQL.
Talk to your database.
All right.
If you'd like to talk to just random stuff in Python.
I don't know how to transition to this.
The topic I want to talk about is an article by Trey Hunter called Python's Mini Command Line
Utilities.
And I knew a lot of this stuff was around, but I always forget about it.
So I love it when people bring this up.
So the thing is, in Python, all the built-in stuff, there's standard library stuff.
And usually you get at it from your Python code by saying import something, like import data
classes or something like that.
But some of this stuff has activities built into the dunder main of it in the subproject.
So that if you write Python-m and then the built-in module, something happens.
And there's a bunch of them.
So this is what this article is about.
And the famous one that is Python-m anti-gravity, which pops open in the KCD comic, which is kind
of awesome that we have that in the language.
I never get tired of that one.
Yeah.
But it does the import this thing.
But so there's a whole bunch of cool tools that I was looking at.
There's general purpose tools that I didn't even know was there.
Calendar is one of them that is actually really handy.
So if you just type Python-m calendar, it prints out the current year's calendar, which
actually, I used to have a desk calendar.
I don't have a desk calendar anymore.
So having something like that pop up really easily, really helpful.
And you can also give it a specific date.
So if you're like, well, what's my anniversary going to fall on in a couple years?
You can look that up.
So really handy to have that around.
There's the HTTP server, which is built in, which is fun.
JSON tool is pretty awesome, actually.
JSON tool lets you nicely format some JSON data.
Some great stuff there, general purpose.
There's categories that Trey has put these into.
And I love the especially handy on a Windows machine category.
These are Unix-y utilities that I often miss when I'm on a random Windows setup.
And I never really remember how to get them safely.
And so having them built into Python, I didn't even know these were here.
Like gzip and tar.
I didn't know that I could use gzip and tar easily on Windows with just Python, built in Python.
How cool is that?
There's a FTP lib has a built-in FTP utility.
You can, it's kind of a quick FTP client.
Nice.
I don't really need Telnet very much.
But some of these are pretty nice.
IMAP lib.
I didn't know that you could curl to read email through Python.
Cool.
Going down, analyzing.
These are analyzing Python code.
Huh.
Tokenize looks fun.
AST, actually, I did know that.
Using AST to get an abstract syntax tree for some code from the command line.
A couple of the ones, what did I want to highlight?
There's working with code.
I don't know.
There's just a whole bunch of fun stuff in here.
You can get Hello World as a command line argument, or the command line tool.
It prints Hello World.
That's funny.
Sure, why not?
Python-M this.
We'll do the Zen of Python.
But an internal demo.
Yeah.
Anyway, fun to check out.
And these are pretty good stuff.
Good stuff here.
Yeah, there's a lot more there than I imagine most people know.
That's pretty awesome.
Pretty awesome.
And there's even a little demo of using cprofile and pstats for getting some profiling of your code.
Very cool.
All right.
What else is cool?
I would say our sponsor.
Let me tell you real quick about Scout APM.
They're big supporters of Python Bytes, so we appreciate that very much.
So if you are tired of spending hours trying to find the root cause of issues impacting your performance, then you owe it to yourself to check out Scout APM.
They're a leading Python application.
They're a leading Python application performance monitoring tool.
It's an important tool.
It's an easy way to find the root cause of the Python application.
queries, background jobs, and the dreaded N plus one queries that you can end up if you do lazy
loading in your ORM. And then you say, oh no, why is it so slow? Why are you doing 200 database queries
for what should be one? So you can find out things like that. And it links it back directly to source
code so you can spend less time in the debugger and healing logs and just finding the problems and
moving on. And you'll love it because it's built for developers by developers. It makes it easy to
get set up. Seriously, you can do it in less than four minutes. So that's awesome. And the best part
is the pricing is straightforward. You only pay for the data that you use with no hidden overage fees
or per seat pricing. And I just learned this, Brian. They also have, they provide the pro version for free
to all open source projects. So if you're an open source maintainer and you want to have Scout APM for
that project, just shoot them a message or something on their pricing page about that. So you can start
your free trial and get instant insights today. Visit pythonbytes.fm/scout. The link is in
your podcast player show notes as well. And please use that link. Don't just search for them because
otherwise they don't think you came from us. And then they'd stop supporting the show. So please
use our link pythonbytes.fm/scout. Check them out. It really supports the show.
Definitely. Definitely. Thank you, Scout.
Okay. How about we talk about Wolfie?
Oh, neat.
Do you know Wolfie?
No, but I like the name.
The name is good. So Wolfie, this comes to us from Patrick Smith. And this is a project from
Chain Guard, which is a company that makes specialized Docker images. So the idea is,
it's based on this idea of distro-less images. Have you heard of distro-less images? I never had.
I'm like, what is this? So normally a Docker image, it shares the Linux runtime kernel,
but then you layer on whatever else you want to add. So, you know, you get the Ubuntu image,
it comes with apt and bash and all those kinds of things. Systemd, which you're very unlikely to be
using in Docker and so on. So those are helpful to have if you might want to run across them,
but they're also, they have a couple of problems. One is they just make the images larger. So you might have a gigabyte image instead of 50 megabyte image,
if you're going to push it to Docker Hub or something like that, or other people are going to download it. And you'd rather have that smaller, right?
Yeah.
And the other one is those things all open up security vulnerabilities and bugs and other issues, right? If there's a bug in something that you weren't using, but it's there, you know, possibly somebody could use that to level up and hack your system, right? That would be less than good.
So these often, these distro-less images often, or containers often come with, without even a package manager like apt or a shell at all, which makes them very small and very constrained in what people can do with them, right?
So you can't like open up a shell and do something if literally the shell doesn't exist. However, debugging them is a challenge because, you know, one thing you can do with a running container that is misbehaving,
as you can say, Docker exec container name, bash or sh, and then get in there and sort of do exploratory stuff, right? So that is a drawback, but they are way more secure, which is pretty cool.
So this Wolfie thing, they make specialized distro-less containers, now that we know what those are, and they're just super stripped down, but so much so that in general, the distro-less images are so stripped down that you can't run Python, right?
For example, or other things. So these come with, where is it down here somewhere? Anyway, it comes with, it's basically distro-less images that are built specifically with just enough to run Python.
So that you can go in and get it working just right. And then once you're sure it's good, you just push it out to production and, you know, count on your logging, I guess. What do you think? Interesting?
Yeah, I think so.
Yeah, much smaller, much more secure because it can't do anything.
And I found the answer, my thought was, why Wolfie? And it's inspired by the world's smallest octopus.
Yes, of course. The wolf octopus, no, Wolfie. It's very cool. Octopuses are cool as well.
And, you know, more and more projects and even projects within companies are caring about software build materials or S-BOMs.
And so minimizing the things that go in your distribution and helps to make that smaller, your S-BOMs smaller.
So having that be part of Wolfie, including high quality build time S-BOMs is a good addition there. That's cool.
Yeah, it's cool you caught on to that. That's another nice thing is they specifically call out all the software build materials and having so much less, well, it makes it easier to do so, I suppose.
Yeah, yeah, definitely.
Neat.
Yeah, indeed.
I ran across recently some, I really like caching. So things like the idea of a memoization or caching of a function.
So it's where if you run a function once, it does it, does the work. But if you run it again with the same input, it just remembers the answer.
But there's different ways to do that. And I'm going to highlight a few that I thought were interesting.
Funktools cache, of course, and I really like that Funktools cache has the cache shortcut because you can just say at cache for a function.
And for a lot of stuff that doesn't have a lot of different input, it works great.
So I've got some projects where it'll be a lot of work, but I call it several times and I could cache that externally, but just throwing cache over the top makes it work great.
So for a lot of cases, just the built-in Funktools cache works awesome.
If you need more detail, cache is actually just a shortcut into LRU cache with the defaults filled in.
But you can set the max size or set type also with LRU cache.
However, you might need more control. And that's where some of these other things come in.
So there's an extension or a third-party library called CacheTools.
And CacheTools has just more, you've got more control over it.
You've got, you can use an LRU cache or a TTL cache.
TTL caches are interesting because they have time to live built into it.
So the cache can disappear after minutes or seconds or whatever makes sense for your application to remember things for a while, but then let them go.
That's super handy.
Yeah, really handy.
Not just because it alleviates the cache management from it being too much, but one of the big problems in computer science is cache invalidation, right?
Like, if it's doing something, I'd say like calling an API, which is the example right on this page, is you don't want to just hit that.
For example, there's a weather API at a location.
Like, given the location, the weather doesn't change that fast.
So let's only refresh every 10 minutes.
You put that on there and boom, and it's completely managed it, right?
Yeah.
And I like the example of weather because we know weather doesn't, the weather forecast isn't going to change that much in the next, you know, I don't know what the 600 is.
I think it's seconds, 10 minutes.
Okay.
So yeah, it's not going to change in 10, you know, refresh it every 10 minutes.
But for various other APIs, you might know about the API, how often it's updated.
And if it's only updated once an hour, you don't need to hit it every time your code hits it.
You can cache that.
That's pretty neat for TTL.
I love that.
So building on top of this is another tool called CacheBox.
So the other one, first one we talked about was CacheTools.
Now CacheBox is a similar kind of thing.
We've got lots of APIs that we can use for it, like LRU Cache and TTL Cache.
It's a similar API as this other one.
But there's also like an LFU Cache, least frequently used.
Least frequently used, I bet.
And so some other things, but one of the fun things about this is it's written in Rust.
So for a couple of reasons.
It's to speed it up a little bit.
And I mean, but there's also, you could probably do larger objects in there because it's a low memory usage.
It says it's a third of the size of a dictionary.
So you're going to use less memory than you would storing it as Python objects.
So that's pretty cool, especially if you're caching like the output of an API that's a big JSON blob or something.
So really cool projects if you're trying to speed things up or save memory with the caching.
So nice.
Yeah, that's very cool.
I did not know about it.
I'm excited.
Yeah, that's very neat.
Cachebox just showed up a few days ago that I was aware of.
I thought, oh, this is interesting.
And yeah, it looks like it's only a couple weeks old.
Two weeks old for the repo.
Yeah.
Very new.
Excellent.
I will definitely give that a look.
All right.
Any extras?
I have had one extra, but then our conversation made me have two extras.
So I'll just throw it out there.
I'll just throw into the show notes, the rocket.chat.
So people have that.
We already talked about that.
So Brian, I've been for many, many years a fan of bartender, not the drinking, but the Mac app.
Yeah.
You know, in Mac, you have this bar across the top.
It's sort of equivalent to the task notification area on Windows.
For some reason, putting stuff up there on Mac is super popular.
I just counted.
I have 28 icons in that thing, and it's ridiculous.
Yeah.
Being able to control that, it's not a little nice.
Yeah.
It's super nice, especially if you're doing presentations like at a conference or for courses or live streams.
You can just hide more stuff away, and you don't have to have it there, you know, showing weird notifications and stuff.
But it turns out, like, this bartender app is pretty cool.
There's some uncertainty about its current status, though.
So bartender was recently sold to another company, but no one announced that it was sold.
And they were trying to kind of like, there's nothing to see here until app monitoring service said, you know, that this is, this is looking a little suspicious.
It's just like, maybe people are buying this to do more deeper tracking.
Maybe they were doing this to do more.
Not illegally, but just sort of digging deeper into seeing what you're doing.
This is bad because it has full screen recording access, access to hotkeys, all sorts.
So it's got a lot of permissions, this app.
Yeah.
So on Mac rumors, let's see.
What's the CEO?
So the original article was PSA bartender Mac app under new ownership, but lack of transparency raises concerns.
Like the guy who sold it didn't even, wasn't willing to acknowledge it until months later.
And the company that bought it still doesn't, won't talk about it.
So it's like, a little sus.
Anyway.
So I want to link to a thing on Mac rumors.
Sorry, windows people.
I know this is not that interesting, but for you, but six bartender alternatives to manage your Mac's menu bar.
And a lot of them are open source.
So for example, I'm using ice, which is available on GitHub with like 8,000 stars, you know, pretty nice.
And guess what?
It works almost exactly the same.
It's free.
It's open source.
You know, why didn't I just use this earlier?
There's a few features coming that it doesn't quite have, but for the most part, I think it's really good already.
That's pretty cool.
I should check that out.
Yeah.
So I've, I've banished bartender just out of a abundance of caution sort of thing.
All right.
That's it for my extras.
How about you?
Uh, just a couple.
Let's see.
Um, I just wanted to let people know, the Python 3.12.4 is out.
So, decent.
I haven't checked to see what is new in dot four, probably book fixes.
So don't know.
Um, but, it's there.
Um, and then, another, another recent release is, I don't usually keep up on these
two tightly, but VS Code, the June is Python for Visual Studio Code.
Uh, and then, the June release, includes, a pytest improvement.
So, there is, there's an ongoing, it's been going on for a while.
They're, they're rewriting some of the Python testing, functionality.
And there's a link in this, in the release note to, to how to, how to change that so that
you can see it.
But if you're using the updated, testing rewrite, there's some changes that should,
should help, just help, help things work a little better.
So, very cool.
Um, nice, nice additions.
That's all my extras.
Yeah.
I, want to say that when I saw you put into the show notes about an hour ago, or when I
saw that they were in the show notes, oh, that three, three 12.4 is out.
I just quick updated a number in the Docker setup.
Boom.
All the apps are upgraded to three, four, 13.4, which is, three, 13.4, which are 12.4,
which is pretty awesome.
No way that all works, right?
All right.
Uh, how about a joke?
That sounds great.
So before I show this, you know, in CSS, we've got different, different settings.
You've got visibility, importance, opacity.
What if you made a series of superheroes or villains or cartoons out of CSS?
Well, that's the joke.
So I'll link to this and we won't go through all of them.
You guys can check it out, but it's called CSS cartoons by Alvaro Montoro.
And we've got the cloud developer and the cloud developer.
Uh, this is a CSS class dot cloud developer.
Background is Azure.
The color isolation is isolate.
Rest is none.
Stress is a 100 and content is none.
They have like cool little pictures of, of like graphics of each.
So check them out.
We have a King.
The position is absolute.
The richness is 100.
The color is Royal blue.
And it says, you got to know your CSS.
It says ampersand greater than colon first child.
So stuff can, you know, the first child of all the things contained directly within it.
All, all colon inherit.
Isn't that awesome?
Uh, let's see.
That's great.
We've got phantom of the opera, Brian.
This is a, there can only be one of these.
So it's not a class.
It's a, ID.
So hash phantom of the opera mask URL hash face.
Backface visibility, hidden visibility, hidden pitch is low.
Volume is soft.
Phantom of the opera.
All right.
We have a winner.
Order is one running first color gold.
And then after, you know, colon colon after content is, the, like the first place trophy.
We have a dictator.
See the dictator down here in the bottom, Brian.
See how he looks.
He's so forbidding.
Uh, a dictator is a class because there can be more than one.
Of course, position fixed exclamation mark.
Important.
Cannot be overridden.
Will change.
Order.
Important.
Opacity.
Zero.
Important.
Everything's important because of the dictator.
You can't overwrite it or change it.
Border.
Double solid.
And then dot country has.
Not dot supporter.
Will change.
Orphans.
Widows.
Important.
And translate.
Uh, 100 V max to zero.
Anyway, it just goes on and on.
Like the scroll bar goes forever.
We've got a basketball player.
I encourage people to check this out.
It's pretty awesome.
That's pretty good.
Yeah.
CSS jokes or cartoons.
Very good.
All right.
Another awesome episode.
Thank you, Michael, for meeting me today to talk about Python.
As always, thank you everyone for listening.
See you later.