Python Bytes - #381 Python Packages in the Oven
Episode Date: April 30, 2024Topics covered in this episode: Announcing py2wasm: A Python to Wasm compiler Exploring Python packages with Oven and PyPI Browser PyCharm Local LLM Google shedding Python devs (at least in the US).... Extras Joke See the full show notes for this episode on the website at pythonbytes.fm/381
Transcript
Discussion (0)
Hello and welcome to Python Bytes where we deliver Python news and headlines directly to your earbuds.
This is episode 381, recorded April 30th, 2024.
And I am Brian Ocken.
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 Ocken, and at pythonbytes, all at fos.on.org.
Connect with us on mass.on.
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 slash 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 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 raveling 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 baby squirrels were playing. So it's a very exciting, but
not as exciting as PI to WASM, a Python to WASM web assembly 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 it be exciting more exciting than baby squirrels well
let's see so really it's about performance this comes from a company called wasmer they make
wasmer edge don't fully understand wasmer edge i'll talk about it for a second in a minute but
they basically have like cloud computing but what you deliver are web assembly things to run rather than full native code to run.
So they can do them closer to the edge, like CDN endpoints, things like that.
But regardless of how you run it, they've come up with this thing called Pyto 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 the 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 interpreting it in a
JavaScript runtime, which I guess I understand why that's slower.
Yeah.
Right.
So pretty interesting.
You just pip install PyToWasm and then you just PyToWasm 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 a 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 that right?
I believe is the way, the Python compiler.
And so that's both awesome, but also has an effect.
And the effect is that Nootka,
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. Yeah. And yeah, not, not to diss anybody that worked on three 12,
three 12 is awesome, but yeah. Oh no. I mean, when we have three 13, three 12 will be kind of
like the mainstream one, right? Not saying nothing's wrong with that.
It's just a lot of people stick one version behind, that's all.
Yeah, that's pretty neat.
Absolutely.
I'm excited to try that for something.
Yeah.
I don't know why.
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 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 um we don't have to pay all the cloud
computer costs just like let them download oxidize um oxide rather and run it locally right
that would be awesome but if you're not doing that now if we could have friend and 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 etc etc so they talk about using cython r python have you heard of
r python transforms typed code into c and then compiles it with the normal c compiler okay i
didn't know i didn't know that but look at that you just say r python hello world.pi and boom
there's a binary executable that's actually actually kind of interesting. Okay. And then some other options,
you could do a Python JIT, PyPy, P-Y-P-Y is probably the most common one of those. And you
can do static analysis with MyPyC. And finally, the one that they chose was Noitka. 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 pipey.
Um, and, but the, uh, or local or your company or something like that.
But in the end, this is the place that we, we shove all the stuff that people share.
Um, and you can browse things like I picked one of mine, uh, pay test check.
Um, and you can and you get pretty quick.
You can see a bunch of stuff about it,
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 like something similar to what you see on pipey eye uh but um
there's some some meta information on the left and you've got there with the readme documentation on
the right the description um but there's also this is kind of fun it's got um the authors is blank i
wonder what i'm doing wrong here but anyway uh it says how to install it in case you didn't know
like pip install pdm rye and poetry instructions for how to install it in case you didn't know, like pip install, PDM,
RIE 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 version.
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 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 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 playing
this up while they're listening it looks very much like the source view the code view in github
actually but based directly on the wheel yeah it's pretty great and then uh even um so even the the
tarball uh 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 uh pretty awesome to look at different uh different things
here um the it is open source um 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 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 this 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 be able to see everything.
So that's why I think that's one of the the um the reasons for the
oven is to try to maybe clean up this interface a little bit but still this is pretty cool um and
then one of the neat things about pipei browser is that it is uh 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
starlet app and um and it even says that one of the benefits of this
is you can use it 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
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 image is neat but it looks
nice it says oven to bake pies no not to bake pies to explore python packages and um 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 very nice i'm a little slow sometimes so uh 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
thorium 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.
There's something on their pricing page about that.
So you can start your free trial
and get instant insights today. Visit buyBytes.fm 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 PythonBytes.fm 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 in YouTube here doing an announcement.
So I want to just give a quick shout out to this new autocomplete 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, 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 ask 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 days
you can't do it you're not doing that so 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 awesome code completion locally
with no round tripping, just pretty neat.
And I think it was on by default on the new PyTorch
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 is 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 def listing, and then it wants to show some videos and some, some view,
right?
So this all could exist.
I'm trying to help people get us 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 and attempt to begin to write return. Do you know what tab will write for you with this?
Hell LM 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 at a tab that at 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 Gary's 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, that's, yeah, like, oh, we're gonna 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 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 an 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 python'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 um so yeah i like that it's just
easier fits in my workflow but also um like you said at work we have we have local like gpt kind of things we can use that are company internal, which is a neat thing for people to do.
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 this works.
So it's pretty cool.
Anyway, good job.
Cool.
Next up.
So that's good news.
We've got some bad news and i got this from
like lots of people so um a lot of people were talking about this on macedon the news is um
that google seems to be shedding python developers at least in the us um and uh there's there's a
bunch of articles around it so um we've got uh registry uh talked about it this is this the
registry i kind of uh talked 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 uh in that
um 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 the net profits to 23.66 billion over for Q1.
So record profits, 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 there's no official announcement, as far as I can tell, from Google yet. It's just since it was under 100 people, they're not announcing it.
Basically leaked messages from team leaders to the teams and stuff like that is what we're seeing yeah um and uh the i don't i don't remember what article i saw this in and i it'd be oh it's from the the register i think uh some of the some
of the teams have been uh reduced in favor of a new team based in munich so um taking people and
uh and then i thought i don't know if this is true or not i heard somebody mention that the 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 um my my uh i guess uh hope
everything goes well for everybody that is part of this and hopefully they land um 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 intensity to like just kill stuff you know there's the google graveyard
and all that sort of things that you hear about. They're the lead of Flutter and Dart, whereas they're not in charge of Python.
It's just unfortunate.
Yeah.
It's going that way.
Yeah.
You've used Flutter and Dart before for projects, right?
Yeah.
It's great.
Yeah.
It's the TalkPython courses mobile app is built in.
Yeah.
I would build it in Python if we had solid options there, but sadly, we're not there yet.
Someday.
Someday.
All right.
Before we call it on that,
I have a quick follow-up to this
that'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's quite a long article.
Let me look.
Sorry. The original. There we go. That's what I'm like. couple of years and it it's quite a long article let me look it's sorry the
original maybe that's what I'm like the original one on where's your head 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, jeez.
So they called for a code yellow, which in Google parlance actually means a really bad
thing.
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 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 in-crapification, if you will, the slightly nicer,
Cory Doctorow term of Google search.
And if you've felt like over the last couple 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 um i may get this wrong because 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 and on your site and look at different what is it uh how many pages they see
look at before they leave i think bounce rate is 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 um i
think for my like blog and stuff anything i'm doing i love a
low balance 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 yep
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 because 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 it's 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 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 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.
Well, those are our topics.
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 LM Studio,
and this is like right in line
with what I was talking about earlier,
the local LLM.
So download, discover, and run local LLMs.
The way it works is you 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, gives you a chat interface, you can say now I'm going to run Mistral, now I want to run
Fi, now I'm going to run whatever, right, you pick the ones you downloaded, different sizes,
all sorts of things. Well, the big deal is Llama 3, which is a very powerful, but not too big
open source LLM for meta is now available locally on LM studio. And boy, oh boy, is it good.
It's really good. So like, for example, I gave it a segment of a Docker composed 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. Does it 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 backoff and it
works like this. And here's the formula to compute like pretty good running locally 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 uh uh this article oh who's it
from i should give him his anyway, somebody, sorry.
It's Python gotchas, strip, Lstrip and Rstrip
can remove more than expected.
And I do this all the time, I forget about it.
So what Lstrip, Lstrip and Rstrip 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, that's a set of characters that it removes. And
that's not usually what I mean, but Python has, um, uh, what do they have? We have remove prefix
and remove suffix that you want to use instead. So, um, 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 user, remove
suffix, remove prefix. And I, 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'd be awesome that lstrip and rstrip and all those things could
take two keyword arguments that were required as keyword. One is characters and another is, uh, 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 as breaking, cause you can explicitly state them. So, well, yeah. And it's,
it's a different, you're seeing thing because strings are iterable. So like, because sometimes I really do want what it does.
Like sometimes I want to take out the, like the dashes out of a string or something.
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 got a couple of funny.
So let's start with the traditional style of funny. 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 uh but here's kind of a paradox or or
something so this is the post that says developers will spend $150,000 on a computer science degree.
Then they go and they go and learn JavaScript on YouTube for free.
And they won't pay 20 bucks for it, basically.
Yeah.
Yeah.
Like, of course, you get that too, right?
The people say, can I get it for cheaper?
Yeah.
And then I've been playing with PyJoke, the actual Python API, not the CLI of it.
And did you know that in PyJ 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's right down your alley.
The first one.
Okay.
Chuck Norris is unit tests.
Don't run.
They die.
Okay.
Let me have it.
If you are good.
Okay. This one's pretty good. Chuck Norris
doesn't need to use Ajax or 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. 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 pie jokes
plural not pie joke singular pretty awesome oh those are those two different things
well oh yeah one is like an expired version from 2014. It 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 well 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 bye