Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to
our earbuds. This is episode 381, recorded April 30th, 2024. And I am Brian Okken.
And I'm Michael Kennedy.
And this episode is brought to you by Scout APM. Listen to their spot later in the show
and connect with your hosts if you'd like to. We're at mkennedy, at Brian Okken,
and at Python Bytes, all at fos.org. Connect with us on mass.org.
And if you are listening and would like to join us live sometime to be part of the audience,
you can go to pythonbytes.fm/live and check that out. And while you're there,
while you're at pythonbytes.fm, go ahead and sign up for the friends of the show list. And that way,
you will get an email announcement after we have everything all polished up and put up online.
So what you got for us first, Michael?
Well, first, I have a new audio setup because I'm traveling this week. And I had a much nicer
setup, Brian, until these guys, these construction guys dropped in and started causing a ruckus.
Can you describe the ruckus? I don't hear any ruckus.
A little breakfast club. Yeah, I'm on the East Coast this week visiting my dad. And there's a
ruckus. So I'm in a slightly different setup. It's a little echoey. So forgive me, folks,
for the echo. I'll be back to the studio next week.
Connecting with Michael in the field.
That's right. Reporting from the field. I did see a wild turkey over there and there have been a
couple of squirrels, baby squirrels were playing. So it's a very exciting, but not as exciting as
Py2 Wasm, a Python to Wasm WebAssembly compiler. Now, Brian, it would be entirely reasonable to ask
or to point out that there is already a Wasm version of CPython. So why would it be exciting?
More exciting than baby squirrels? Well, let's see. So really it's about performance. This comes from
a company called Wasmr. They make Wasmr Edge. Don't fully understand Wasmr Edge. I'll talk about it for
a second in a minute, but they basically have like cloud computing, but what you deliver are WebAssembly
things to run rather than full native code to run. So they can do them closer to the edge,
like CDN endpoints and things like that. But regardless of how you run it, they've come up
with this thing called Py2 Wasm. And so you can take your code and compile it to this. And it's not
quite as fast as true native CPython. But what I didn't realize that CPython Wasm is like one fifth as
fast as native Python. Okay. So this is three times faster than the alternatives if you're going to do
anything WebAssembly. So that's pretty cool. And that makes it maybe two thirds the speed of
truly native Python rather than compiling C to WebAssembly and interpret it in a JavaScript runtime,
which I guess I understand why that's slower. Yeah. Right. So pretty interesting. You just pip install
Py2 Wasm and then you just Py2 Wasm your program and you output your .wasm. And actually that,
I mean, you can run it in Wasmr, but it also kind of just opens up the possibility to run
interesting things on the web and web-based platforms in general. Right?
That's pretty, pretty easy workflow. Yeah. It doesn't look too bad. And the pip install one is one
time, right? Like you get that set up. Good to go. Now, this is actually based on Nutka.
Am I spelling it? Say that right? Nutka. I believe is the way the Python compiler. And so that's both
awesome, but also has an effect. And the effect is that Nutka, oh, I'm saying this close, right?
Only supports 3.11 so far. And so your code will only work on Python 3.11. But honestly, these days,
3.11, 3.12, they're real similar, right? There's not a lot of features that we go, like,
can't use it. Can't use 3.11 these days, right? That's kind of as mainstream as you get. Most
most people that have a lot of really hard requirements for stability are a step behind
anyway, right? Yeah. Yeah. And yeah, not to diss anybody that worked on 3.12. 3.12 is awesome.
But yeah. Oh, no. I mean, when we have 3.13, 3.12 will be kind of like the mainstream one,
right? Not saying nothing's wrong. Nothing's wrong with that. It's just a lot of people stick one version
behind that song. Yeah. That's pretty neat. Absolutely. Excited to try that for something.
Yeah. There's a bunch of, exactly. So it's awesome. I so want a front end framework to be based on
PyScript and the MicroPython runtime and all of that, but we don't have that yet. And so until we do,
I don't have a huge use case. I mean, in the data science world, there's a lot of, there's a lot of
reasons for like, hey, can we push the compute for this computationally expensive thing to the browsers
so that we don't have, we don't have to pay all the cloud computing costs, just like let them download
Pioxide, Pioxide rather, and run it locally, right? That would be awesome. But if you're not doing that,
now, if we can have front end framework in Python, I'd be all about it. Well, just one thing to wrap
up this article here that announces this. They also talk about like, well, how could you get Python into
WebAssembly? There are ways to do it. There's ways to make it faster. You could use a subset of Python. You
could use a JIT. You could use static analysis, et cetera, et cetera. So they talk about using
Cython, R Python. Have you heard of R Python? Transforms typed code into C and then compiles
it with a normal C compiler. Okay. I didn't know. I didn't know that, but you just say R Python,
hello world.py and boom, there's a binary executable. That's actually kind of interesting. Okay.
And then some other options you could do Python JIT. Pypy, PYPY is probably the most
common one of those. And then you can do static analysis with mypyc. And finally,
the one that they chose was Noitka. Noitka. Oh, well, right. And then they talk about how they
use it here. So if people want to dig deeper, there's a lot more to go here, but I think that's
enough for introducing the idea. Yeah. And I do appreciate that they talked about their trade-offs
and why they picked one over the other and stuff. Yeah, exactly. Pretty neat. Pretty neat as well.
All right. Over to you. Well, I want to talk a little bit about where you get packages from.
So normally I take a look at pypi.org to look for stuff and that's kind of where stuff's coming from.
And unless you have a local repo, if you do pip install, it's coming from PyPI.
Or local or your company or something like that. But in the end, this is the place that we shove all
the stuff that people share. And you can browse things. Like I picked one of mine, pytest-check.
And you get pretty quick. You can see a bunch of stuff about it. Well, the maintainers, some of the meta.
And the reason why I'm covering this is because that's kind of what you get with PyPI, this browse
feature. But there's a couple other options that I wasn't aware of. And I'm pretty excited about Oven.
So both Oven and what's the other one? PyPI browser. So let's take a look at Oven. So I just learned
about this recently. It's from Frostming and a really slick interface. And when you search for
something here, you get something similar to what you see on PyPI. But there's some meta information
on the left and you've got the readme documentation on the right, the description. But there's also,
this is kind of fun. It's got, the author's blank. I wonder what I'm doing wrong here. But anyway,
it says how to install it in case you didn't know, like pip install, PDM, Rai and poetry
instructions for how to install something. Kind of fun. The thing that I really enjoy is some of the
extra stuff that it's adding. Some of the extra stuff is a really great browser for what,
great look at what the versions. So this is a really clean, old version interface and how old they are.
And then the file browser is kind of amazing. So you've got both wheels. So I'm just
distributing both a wheel and a tarball. And within the wheel, you can check to see,
you can just see all the files in here. Oh, you can even look inside individual files. This is pretty
amazing to be able to inspect, inspect what, what you're getting with your wheel before you even try
to install it. So that is cool. It's really for people who are not pulling this up while they're
listening. It looks very much like the source view, the code view and GitHub actually, but based directly
on the wheel. Yeah, it's pretty great. And then even, so even the, the tarball pulls things apart and you
can see, see what's in there through, through the tarball. This is pretty amazing. All the meta,
all the meta data, and then just everything. You can just completely view it without even installing
it or downloading it or anything. So pretty awesome to look at different, different things here.
Yeah. It is open source. It is based on, I think it's JavaScript. I think JS, JavaScript and something
called Remix, which I'm not familiar with, but pretty new project, but pretty exciting. I think this is
gorgeous and helpful to the community. And then the, I think I saw this on the announcement for Oven,
was comparing it to also PyPI browser. And I'm like, I didn't know about that. So let's take a look at
PyPI browser. So pypi browser, pypi.browser.org. Also as you can search for packages. And this is not
trying to replace the PyPI interface too much. It's just so you can take a look at wheels. So
being able to look at the metadata and the package content within, oh, wow. You can just like see all
the stuff. So yeah, PyPI browser allows you to go in and look at all the code, but there's a little more
clicking around to, to be able to, to see everything. So that's why I think that's one of the, the, the
reasons for the oven is to try to maybe clean up this interface a little bit, but still this is
pretty cool. And then one of the neat things about PyPI browser is that it is based, it's written in
Python, it's open source, both are open source, but this one's written in Python on Starlet. So it's a
Starlette app. And, and it even says that one of the benefits of this is you can use it as, as a browser
for a private PyPI registry at your company or an internal registry. So that's pretty cool. So I
don't know what the difference is with try to, between trying to install this versus other things,
but anyway, a couple of neat ways to browse Python packages. Yeah. Both are new to me and very
interesting. I like oven a lot. It looks real good. Yeah. The, the, the interface is just gorgeous.
Of course, of course, this is mostly the images neat, but it looks nice. It says oven to bake pies.
No, not to bake pies to explore Python packages. And, and for a while I was like, what's going on?
What? I don't get the, the joke. I honestly, I didn't get the joke for a few minutes and then it's
the pie is in the oven. I get it now. Yeah. Yeah. Very nice. I'm a little slow sometimes. So do
you know what's not slow scout APM. 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 performance monitoring tool, APM, that helps you identify and
solve performance abnormalities faster and easier. Scout APM ties bottlenecks such as memory leaks,
slow database 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 the 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 by them by side of him slash 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 by them by side of him slash
scout. Check them out. It really supports the show. Right. Thank you, scout. Now on to the next thing,
which is a freeze frame of Paul Everett and YouTube here doing an announcement. So I want to just give a
quick shout out to this new auto complete code intelligence engine that's in PyCharm. People know I'm a big fan of
PyCharm, right? I talk about it all the time. But if you have any of the pro tools, including PyCharm Pro, there's
something that you've noticed. But if you haven't used it lately, you wouldn't notice, obviously. And they've added, you know, how people have, you know,
have copilot and some of these other things that they can plug into their development tools, right?
Yeah. Well, the way that works is it takes a section of your code or your code comment that you asked,
instructed to do a thing and then a section of your code and it sends it off to the cloud and stuff happens.
That send it off to the cloud. Some companies may frown upon it. I believe your company says,
nine, do can sneak. You can't do it. You're not doing that. So being a German company, they say it that way.
That's why I said that. So this is awesome because it's sort of like that, but that's probably the wrong
mental model. But nonetheless, it's like totally local. So it comes as a plugin for PyCharm and others
if you have the pro version. And it just lets you do like awesome code completion locally with no round
tripping. Just pretty neat. And I think it was on by default on the new PyCharm, because why not? I want
to give you an example to give you a sense so people otherwise it's just like, hey, this thing, it's neat. It
helps you write code. What does that mean? So here's a little bit of code I wrote. It's a flask
view endpoint and it's using blueprint. So it says at blueprint dot get slash listing. It says a function
depth listing. And then it wants to show some videos in some, some view, right? So this is all code
existing. I'm trying to help people get it. This is where it starts videos equals, you know, some
database query to get a list of video objects. Right? Yeah. Now, if you type the word R E T,
an attempt to begin to write return, do you know what tab will write for you with this LLM?
Return flask dot render template, parentheses slash home slash listing dot HTML, because there's a
hierarchy of the templates and that is the correct one. And videos equals videos, close parentheses,
tab to write that. Yeah, that's a that's amazing. You just do that all day. Just that a tab that
added a tab that had a tab. Sometimes it gets it wrong. And sometimes it's close enough. You tab it
and correct it. And sometimes it gets it. Actually, this is exactly what should be written, which is
insane. And some pretty long, like you're showing some pretty long stuff that I'm surprised by some
short stuff. I'm like, Oh, yeah, that's probably that's right. Yeah, that's right. Yeah. Yeah. Like,
oh, we're going to sort the functions by like, most used rather than alphabetical only and like
something silly like that. Right? It's not that it's way more than that. But there's been times
now I'm so I'm so loving this because there's times where I'm calling some API function. And
I'm just about to think, I don't use this very often, I have to look it up. And it just like pops
it in. And it's correct. I'm like, Oh, yeah, that's exactly what I wanted. Thank you.
Yeah, I'm already getting used to it to the point where I can't live without it. Now. This is
yeah, incredible extra feature. It is. And where it frustrates me is where I'll type a little too much
and it'll go away. I'm like, No, I should have just accepted it. I didn't read. How do I get this back?
Yeah, I've actually like started over. I'm like, okay, delete the line and start over because that's
easier. It's going to be quicker than writing the rest of it. Absolutely. Yeah.
So anyway, like I know PyTron's pro is a paid thing, but it's also one of the very
most common tools. And this is not paid, but I think it's awesome. And so I just wanted to give
a shout out for it because so many of these coding assistants do all this magic by sending all of your
code to the cloud, and they've got the cloud latency and all that. And this is just nice and local and
sweet. Yeah, that's the part that I really. So yeah, I like that it's just easier fits in my workflow.
But also, like you said at work, we have we have local like GPT kind of things that we can use that
are company internal, which is a neat thing for people to do. But but this is just local and it
doesn't even go anywhere. So it's super fast. I can even have my laptop unplugged and work.
This works. So it's pretty cool. Yeah, good job. Cool. Next up. So that's the good that's good news.
We've got some bad news. And I got this from like lots of people. So a lot of people were talking about
this on Mastodon. The news is that Google seems to be shedding Python developers, at least in the US.
And there's there's a bunch of articles around it. So we've got registry talked about it. This is this
the registry kind of said Python and Flutter teams latest on the Google chopping block. Never mind,
the record revenues cost must be cut. And I this I kind of like this article in that it highlighted that
in this time where they're like laying off a lot of great people, they last week, they announced a
one year jump on net profits to twenty three point six six billion over for cap for Q1. So record profits.
It's I don't know if that's record profits, but really great profits. And yet that's not enough.
And they're cutting people. And I saw it all over all over Mastodon. TechCrunch has some highlights of
different people posting, including from Thomas Wooders, who's one of the Python core people.
He's on the steering council, too, as well. Oh, yeah. And also Dart. So Google lays off staff from
Flutter, Dart and Python teams. And I and there's no official announcement as far as I can tell from
Google yet. It's just since it was under 100 people, they not announcing it basically leaked
messages from team leaders to the teams and stuff like that is what we're seeing.
Yeah. And the I don't I don't I don't remember what article I saw this in and I it'd be oh, it's from the register.
I think some of the some of the teams have been reduced in favor of a new team based in Munich.
So taking people in and then I thought I don't know if this is true or not. I heard somebody mentioned that
some of the laid off people are getting or having to retrain having to train their replacements, which is
tacky and yicky. So hopefully that's not true. Anyway, my my I guess hope everything goes well for
everybody that is part of this and hopefully lay land land on their feet. Well, so good luck.
Yeah. Sorry, folks. Brian, it's like they want to try to take out my entire tech stack
Python and then the mobile apps are Flutter and Dart. And I was like, oh, come on.
I'm actually more worried about Flutter and Dart because Google is such a density to like just kill stuff.
You know, there's the Google graveyard and all that sort of things that you hear about. And they're the
lead of Flutter and Dart, whereas they're not in charge of Python. It's just unfortunate.
Yeah. Yeah. So yeah, you've used Flutter and Dart before for projects, right?
Yeah, it's great. Yeah. So it's the talk Python courses mobile app is built in.
Yeah, I wouldn't build it in Python if we had solid options there. But sadly, we're not there yet. Someday.
All right. Before I hold it on that, that all of them, I have a quick follow up to this. It's part of this.
Okay. This is not as timely, although it's an article from seven days ago. It talks about the
history last couple of years. And it it's quite a long article. Let me look. It's sorry. The
original. There we go. That's what I'm like. The original one on where's your ed at, which is an
awesome domain. But it's a really long write up and it's entitled The Man Who Killed Google Search.
And basically it documents the struggle between the search team whose job is to build features
that are better for you, better for me, better for everyone. And the ad team whose job is to make you
do more queries. So more ads show up so that you might click them. Oh, so they called for a code yellow,
which in Google parlance actually means a really bad thing. Like code red would probably be the way
people would think of it. It says people are finding what they look for too quickly and leaving.
So what can we do to like make them see more ads basically? And there was a big struggle for a
couple of years. This all started in 2019, but it's basically the, the in crapification,
if you will, the slightly nicer Cory Doctorow term of Google search. And if you've felt like over
the last couple of years, Google search has gotten worse, it's on purpose so that you will spend more
time seeing ads and maybe clicking them. How about that? Well, yeah. So one of the things that people
look at is your bounce rate. So, I may get this wrong cause I'm not really a, like a stats wonk, but,
um, bounce rate, I think is, I don't know what it is. It measures how, how many, how long people stay
in on your site and look at different, what is it? how many pages they see, look at what, before they
leave? I think bounce rates, you, you get to one page and you leave, you don't subsequently explore
the page. Okay. So a lot of people don't want that. And I, I personally, I think for my like
blog and stuff, anything I'm doing, I love a low bounce rate. That means that my, my analytics and
whatever, or my Google search terms and all that are correct. And people can find exactly what they're
looking for right away and they don't need to click around and find something else, but I'm not, I'm not
like pushing ads. So yeah. Anyway, I'm off to read this. This is very interesting. Yeah. I read it yesterday.
It's really interesting and it's not inspiring, but it is interesting. And the reason I even brought it up,
not just cause the word Google appears in both, but the, the like, Hey, we don't care so much about the
tech. We're not doing this to support the community. We need our cut. And what can we do to make that
happen? It feels very much like the same vibe of motivating a lot of these layoffs and like,
yeah, we don't really like, how do we make money on ads from flutter? I don't think we do. Can we
get that out of here? Like these people are just dead weight, like that kind of thing. Right. And
these a little less so for Python, but still also, but this is the, this isn't a struggling company.
This is one of the most profitable companies in the world. I think they just became a $2
trillion stock market valuation. So try like, it's not just, we need to make money,
but we need to make more and always more and always more. Never enough.
So anyway, it's too bad. Ah, well, those are our topics. do you,
do you have anything extra since you're, I am feeling not very extra. I have one extra,
one extra. This is good. Cool. So previously I've spoken about L M studio, and this is like right in
line with, what I was talking about earlier, local L L M so download discover and run local L L M
is the way it works is you'd run this app. Then you tell it, you basically search hugging face
models and they get rankings and all that kind of stuff. And then it just downloads a whole bunch of
them. It gives you a chat interface. You can say, no way to run mistral. Now I want to run fine. Now I
want to run, whatever, right. You pick the ones you downloaded different sizes, all sorts of things.
Well, the big deal is llama three, which is a very powerful, but not too big open source. L L M from
meta is now available locally on L M studio. And boy, oh boy, is it good. It's really good. So like,
for example, I gave it, a segment of a Docker compose file with concrete settings. I said,
tell me what this does and, tell me not just what do these mean, but exactly what does each command
do? Like when it says restart, does it just, and it says restart five times until you consider it failed.
They just try as fast as it can. does it use, is there some kind of way to set a timeout? It's like,
oh no, no, it uses an exponential back off and it works like this. And here's the formula to compute.
Like pretty good running locally. I highly recommend. That's pretty cool. Nice.
So that's my only extra. My one extra is just a public service announcement because I run into this
all the time. I don't know. It's a basic Python thing, but, this article, oh, who's it from?
I should give us anyway, somebody, sorry. it's Python gotchas strip L strip and our strip can
remove more than expected. And I do this all the time. I forget about it. So what else strip L strip and our strip
do is they take a string and they strip characters out of it. And if you give it like a word,
it doesn't take the word out. It takes it's a, that's a set of characters that it removes. And
that's not usually what I mean, but Python has, what do they have? We have removed prefix
and remove suffix that you want to use instead. So, if you, if that's what you want to do,
if you just want to remove something off the beginning of the, of a string, use remove suffix,
remove prefix. And I bring this up because I always run into it. And, and then in, in my little test
example, it works. And then I put it in a bigger project and it doesn't work. What's going on. So
that's it. That's it. PSA. Yeah. Yeah. That's it. So anyway,
if you could start over, I think it would be awesome that L strip and our strip and all those things
could take two keyword arguments that were required as keyword. One is characters and another is,
sub strings or something. You just say characters equal this or sub string equals that or something.
But you know, even changing keyword names, primary names is breaking because you can explicitly state
them. So, well, yeah. And it's, it's a different interesting thing because strings are iterable.
Um, so like, because sometimes I really do want what it does. Like sometimes I want to take out the,
uh, like the, the dashes out of a string or something like, yeah. Anyway. All right. Oh,
let's see who's this from. This is Andrew Wagner, Andrew. So thanks Andrew. all right. Something
funny. Oh, I got some funny today. I had a couple of funny. So let's start with the traditional style
of funny. So this comes to us from dev humor and both you and I work on courses, put a ton of energy
into them. We don't charge that much money for them. but here's kind of a, a paradox or, or
something. So this is the post that says developers will spend $150,000 on a computer science degree.
And then they go and they go and learn JavaScript on YouTube for free and won't pay 20 bucks for it.
Basically. Yeah. Yeah. Like, of course you get that too. Right. The people saying like,
can I get it for cheaper? Yeah. And then I've been playing with PI joke, the actual Python API,
not the CLI of it. And did you know that in PI joke, you can specify a category. And one of the
categories is Chuck Norris. So let me read you. I'm just going to get like five, five Chuck Norris
programming jokes for you. Are you ready for this? This one is right, right down your alley. The first.
Okay. Chuck Norris is unit tests. Don't run. They die. Okay. Let me have a little bit of a good. Okay.
This one's pretty good. Chuck Norris doesn't need to use Ajax for JavaScript prospects. Chuck Norris
doesn't need to use Ajax because pages are too afraid to post back. Anyway, Chuck Norris can dereference
null. Okay. That's, that's my favorite so far. Hold on. Hold on. Okay. Last one. Chuck Norris's
programs never exit. They are terminated. Yeah. Okay. That's pretty good. Yeah. So anyway,
if you pass the Chuck category to PI jokes, plural, not PI joke, singular, pretty awesome.
Oh, those are, those two different things. I joke. Well, oh yeah. One is like an expired version
from 2014. Jokes has at least been updated in 2019. Okay. Yeah. All right. Looking for contributors
there, man. Exactly. Sure. We can get a few more of these. No one has ever paired program with Chuck
Norris and lived to tell the tale. We can tell the tale of the podcast, Brian. Yeah. Well,
next week, are you back in town or I am back in town? Okay. Everything is back to normal. So we'll talk to
everybody next week. Yeah. I'm glad we're able to do the show anyway. So yeah. Yeah. Good to see you.
All right. Bye. Bye.