Python Bytes - #386 Major releases abound
Episode Date: June 4, 2024Topics covered in this episode: NumPy 2.0 release date is June 16 Uvicorn adds multiprocess workers pixi JupyterLab 4.2 and Notebook 7.2 are available Extras Joke See the full show notes for thi...s episode on the website at pythonbytes.fm/386
Transcript
Discussion (0)
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 386, recorded June 4th, 2024.
I am Michael Kennedy.
And I am Brian Rockin.
This episode is brought to you by Mailtrap.
I want to tell you more about them later.
And I also want to let you know that you can find us over on Fostodon.
We are Fostedonians as
we've said before if you want to talk to us on
Mastodon the links are in the top of your
podcast player show notes we're also
on X but do a little bit
more stuff on Mastodon
so check us out there also you can
find us streaming live
at exactly this time
right now Ryan
which is usually 10am.m. Pacific time on a Tuesday.
So just pythonbytes.fm slash live,
and you can be part of the live show.
If you want, watch the older videos there if you like,
or just subscribe in your podcast player.
We really appreciate that.
Finally, interest in our email that you've been writing.
There's a lot of people signing up for it, Brian.
So if you want an artisanal handcrafted digest of the show in written form just visit pythonbytes.fm click on newsletter right there
in the center and enter your email address we won't share it but we will send you an email
after every show about what we covered so you have it saved if you like yeah yeah all right you want
to kick us off brian i will so um this comes as a suggestion from somebody, and I'm sorry I didn't write the name down.
So thanks. We do love it. I love it when people share important news with us and say,
hey, you really should cover this because it's important. Thank you for that.
So what am I talking about today? I'm talking about NumPy 2.0.
And I was searching for it. I thought we'd covered some of the changes in
numpy 2.0 but i i don't know if we have so numpy 2.0 has been uh in the works for a long time the
reason why i'm bringing it up right now is because the release date is june 16th it's right around
the corner and numpy is both even you're probably using it uh I guess I'll just say that.
If you're using any data science or any machine learning or something,
you're probably using it,
even if you don't use it directly.
But you probably are using it directly.
Anyway, lots of changes to 2.0.
We're linking to an announcement.
We've got the main page, numpy.org, announces it.
You can just go there if you want.
But there's also a news item for the release for the June 16th.
There is some cool migration guides.
So I'm not going to go over a lot of the details, but there are some breaking changes with this.
So I'll go over a few things.
First off, went over and looked at the migration guide.
Let's see the release note.
Migration guide. I thought this was super cool.
So the migration guide is around to help you go through,
navigate some of the changes that might be,
might be the most problematic.
But one of the cool things is Ruff is helping out.
So if you're using Ruff greater than version 0.2.0, you did added a rule for NPY 201.
So but you can just look at the migration guide and find this. And you select this rule and run
rough and it will and they can just run check or you can just run rough to correct. Rough is around to help you with a lot of the stuff in this migration guide to try to modify your code from older NumPy to the NumPy 2.0.
So that's really cool.
I would probably start there.
Also, making sure you have tests around your code to make sure your code is working before and after the migration.
And then the release notes gets down to a lot of the nitty gritty stuff.
There's new string stuff, there's performance improvements, but there's also hopping down,
there's a lot of breaking changes.
And, you know, we need to allow projects to do this.
So I think this is a good thing that they're moving towards some changes in NumPy.
Yeah, quite a big deal for a 2.0 of NumPy.
It's been around a super long time, 15 years or something like that.
So they must take it seriously.
That was released in 2006.
Yeah.
And like I said, this 2.0 migration to make sure that they were doing the right deprecations and omissions and changes necessary for breaking some backwards compatibility. But for good reasons, I think it's, yeah, just heads up, everybody. So yeah, awesome. Well, that's a good one to cover for sure.
I have another exciting one.
Let's jump over to that.
So if you are a fan of UVA corn, so UVA corn is one of the ways you can run ASGI, ASGI
web app.
So things like Quartz, FastAPI, many others. You can use uviacorn, and it's definitely the recommended way
or the at least suggested way that you run FastAPI for development.
But then when you go into production, well, you've got challenges.
So, for example, you want your web server to look and see if your web app crashes
for whatever reason,
like something went wrong, excuse me, something went wrong with it.
Something, um, maybe it ran out of memory.
I don't know all these things, right?
Yeah.
You need the app to sort of look at that and say, well, we're going to restart it
because it looks like it's hung up or it looks like it crashed and bring it back.
The other thing you need to be able to do is you need to be able to potentially scale out across processes so maybe i've well not maybe
at pythonbytes we have an eight cpu server if we just create one process you know because of the
gill and other things it might be kind of blocked up if it's processing some slow request we don't
want it to have to just queue up
behind it. You want to be able to say, well, this one is busy, but there's three other processes
that are clones of this thing running and hand it off to one of them, right? Typically that's
done in production by using G-Unicorn with UVicorn workers, which is like, why am I using two servers
like to kind of manage the CEOo so like g unicorn manages uv
acorn running this stuff like what a mess right so the news of this item is uv acorn now does all of
that stuff itself it no longer needs g unicorn and this news comes from us from john hagan so thanks
for shooting this our way so this is filed under the new multi-process manager and it says the multi-process
manager introduced by this includes a process keep alive and process hung detection. It also
imitates g-unicorn and uses a bunch of different types of signals to control the child processes.
And there's even, I haven't opened it up yet but I will there we go I'll include a link to
how you use this in production so it's pretty easy you just say uveacorn and then the module
name and then the variable name of the app so like main colon app super common but then the new thing
is dash dash workers and you can specify how many workers you want. The documentation has four.
It says, unlike G Unicorn, UV Unicorn does not use Prefork, but uses Spawn, which allows UV Unicorn's
multi-process manager to work well on Windows as well. The default process manager monitors the
status of child processes. Those are actually the things handling your web requests. And it
automatically restarts child processes that die unexpectedly.
That's a little morbid.
Not only that, it'll also monitor the status of child processes through the pipeline.
And if it gets stuck, it'll be killed off and restarted and so on.
So that's the new thing.
And if you're already using uveicorn, especially if you're using uve corn workers with G-Unicorn, this might be a pretty awesome way to simplify things.
Not only it might be, you kind of need to because the UVA corn workers have been deprecated as well.
Oh, the G-Unicorn workers?
You mean?
Oh, yeah.
Oh, yeah, that's right.
It is deprecated and will be removed in a future release.
So I guess get busy, people.
Yeah.
So exciting news.
Yeah, indeed.
Changes.
Very exciting.
Now, do you know what else is exciting, Brian?
MailTrap.
Yeah.
Our sponsor.
Yeah, let's talk about them for just a second.
This episode is sponsored by MailTrap, an email delivery platform that developers love. An email sending solution with industry-best analytics, SNTP, and email API,
as well as SDKs for major programming languages and 24-7 human support. Try for free at
mailtrap.io. Over to you. What you got nextie. This, this, I did write down who suggested this suggested by Vic Gelson.
So thanks Vic.
Pixie is a package management made easy.
So another package manager thing.
This is a,
is this something that says conda package management simplified.
So this is not trying to replace pip,
but really trying to, and you know, things like that, but it's trying to replace pip, but really trying to, and things like that,
but it's trying to replace conda or build on conda.
So I haven't really dug too much into this,
but I think it's an interesting project.
This is cross-platform written in Rust,
but it's also not just about Python.
It's about other languages as well.
So the highlights are it supports multiple languages,
including Python.
C++ are using conda packages.
And there's, yeah, some exciting information around it.
It's cargo-like.
I think that it's built thinking, you know,
trying to get conda to kind of look like cargo.
Like I said, I haven't tried this, but it looks exciting.
There is a Pixie tutorial for doing Python development with Pixie.
This walks through creating a Pixie Py project, which creates a PyProject tunnel. I found this interesting that it is using setup tools as a backend.
And then there's some extra PixieProject stuff around CondaForge.
So I think this is a tool, if you were publishing to the Conda space,
this might be a tool worth looking into to try to manage your conda environments.
Yeah, definitely.
It's a super cool project.
I feel like there was some collaboration between them and maybe the UV folks.
I can't remember.
But yeah, it's a super cool project.
I actually had Wolf Volparek and Ruben Arts on last year in October to talk about this on TalkPython.
So if you want to hear them dive into why they built it and all the plans there.
And actually, we talked about some other stuff as well that they're doing.
We talked about like NixOS and so on.
So, yeah.
Interesting.
Awesome.
Yeah, it's awesome.
There's a thousand flowers blooming in the packaging space right now.
It's very exciting.
Yeah. So this was mentioned by Vic,
but he also gave us a little bit of what his take on it is.
So I'm just going to quote from Vic right now.
He says, Pixie is a project manager written in Rust
that allows you to build Python projects
without having Python previously installed.
That's interesting.
It's installable via Homebrew. There's
support for support in VS
Code and PyCharm via plugins to
deal with this. By default,
Pixie fetches packages
from CondaForge, so you
get the scientific stack in a pretty
reliable and performant build.
If it's not there, it looks
on PyPI
or there's a possibility to look on PyPI.
So Vic tried to use it.
He was really impressed and got his Jupyter environment
with QPy using NVIDIA GPUs working really quickly.
So at least one person says it's a pretty cool thing to try.
Yeah, scroll up on that screen you got there.
Scroll up or the other way?
Other up.
Yeah, to the top.
Yeah.
2,100 people think it's a pretty good way.
The number of stars there.
Yeah.
Yeah.
Exactly.
All right.
Final one for me is Jupiter.
So we already talked about NumPy,
which also is the foundation of so many other data science projects. So here's
maybe looking at it from the other direction of the data science space, looking in from the top,
from the UI. So JupyterLab 4.2 and Jupyter Notebook 7.2 are now available. So it's pretty
awesome. JupyterLab includes three new features. I'll give you some shout outs on them.
20 enhancements, 33 bug fixes, and 29 maintenance tasks included by 39 contributors, which is pretty awesome, right?
Yeah.
And Jupyter Notebook, I think, carries, you know, takes some of these forward as well.
So also has a bunch of fixes.
All right.
So what are some of the features?
Easier workspace management with the GUI.
So you can, instead of using the CLI
or just grabbing a URL, for example,
if you want to have it open up a particular notebook
when you launch it or something,
you could create a workspace with that open,
I believe, instead of just pointing to a URL
to that particular notebook, right?
So now there's like a UI for workspaces
that you can control. Rename them, reset them, delete them, and so on. That's pretty cool.
You have recently opened and closed files. There used to be
an extension called JupyterLab-Recents to give you
access to recent files and recent directories, and now that just comes built in.
So I guess if you have the extension still installed, you'll really know what recent files and recent directories. And now that just comes built in. So I guess if
you have the extension still installed, you'll really know what recent files you had, but
now it probably disables it or something. It has full notebook windowing mode by default.
And that's not like a screen layout type thing. Suppose you have a notebook with a thousand
cells and their output, and those outputs have interactive notebook widgets
and Jupyter widgets,
and they've got a bunch of graphs and stuff.
If you open that thing up and it just goes,
well, we're gonna render all thousand items,
you know, it might take a moment, right?
Yeah.
So instead what it does is it basically renders
only the cells visible on the window,
which should be for as it gets larger and larger,
should be more important for performance.
Improved shortcut editor.
So you can do a bunch of different better things.
In fact, like even change default bindings and stuff.
Dark, high contrast theme, more keyboard shortcuts or putting some of them back.
Like control D, spinner sword, allow users to delete a line and that type of stuff.
So there you have it. like control D, it's been restored to allow users to delete a line and that type of stuff. So,
there you have it.
If you are a notebook person,
go forth and get
the new one for you,
whether JupyterLab
or Jupyter Notebook.
That's pretty exciting.
I'm glad to see
this is continuing
with the new releases.
Yeah,
it's a really nice,
really nice way
to work with Python
and data science
and all the things.
All the things.
How extra are you feeling today?
I got a few extras.
All right, do it.
Tell us about them.
Okay, a couple things came from Hugo von Kaminada.
Sorry if I messed this up, Hugo.
But anyway, some encouragement for us to test Python 3.13.
So Python 3.13 is in, the beta's out,
and we're trying to, it's got some interesting stuff in it,
like the free threaded mode.
So a couple links here to encourage people to help test
and some blog posts to help you know how to test it. So help test Python 3.13.
There's an announcement here, strongly encouraging people to test. And then a specific test around
the free threading Python without the GIL. And a reminder that some people call this no GIL,
but we don't like to say that anymore. So the free threading mode
and how to test that. And that one's a little tricky because you've got to,
there are some official installers, but you can build it yourself as well. And it's available
as well and get dead snakes. There's a question marker on GitHub actions. It'd be great if
that works, like to hear back from people. But we really want this to go
well with this because it's a cool project. So help test that. So that's around the Python.
That's probably the biggest change facing people using 3.13 and packages that you might be using
that are on 3.13 and all those things, because those were not built with with this in mind whereas everything else is built at least with the concept of backwards compatibility
right but this one right but there's a break it break i'm sure there's places where they've had
to change this the normal stuff as well just to keep get that ready for that so um i encourage
people even if you're not planning on testing any part of the GIL versus with free threading, to test 313 in any way just to make sure that there are no surprises with your project and report them if there are.
Last thing, I have been fairly quiet on the Python test podcast recently, but there is an episode that came out the other day, how to get PyTest to import your code under test.
So 2.21 is out.
These are not going to come out very regularly,
but occasionally they'll drop, so I'll mention them.
And yeah, there's a new one.
So those are my extras.
Yeah, cool.
What's very excellent about podcast clients
is even if something doesn't come out for six weeks,
when it does, boom, it just shows up right in your list.
Yeah.
People will know.
Do you have extras?
I do.
I have just one quick bit of follow-up.
So remember, Brian, we talked about the higher order company
and we talked about Bend, a programming,
a parallel programming language that is Python-like.
It looks like Python, that sort of thing.
I feel like I maybe gave the impression that it
is python it's not python it's just python like it's so you could look at code and say yeah that
is python but you might not be able to import a bunch of things or there's certain things you
can't do right so it's a big time subset and maybe uh not exactly even a subset right anyway i got
some uh some follow-up from Bernat Gabor.
I just wanted to read just so,
because I think it sounds like he's got more experience
than I do for sure.
So it says, bend looks roughly like Python,
but is nowhere there actually.
For example, it has no for loops.
Instead, you're meant to use the bend keyword,
hence the language name, to expand calculations
and another
keyword to join branches. So basically think of something that resembles Python at a high level,
but without being compatible with that and without any of the standard library or packages
that the Python language provides. That being said, it does an impressive job at parallelization,
but essentially it's a brand new language with new syntax and paradigms you'll have to learn.
It just shares the first look similarities to Python.
So, yeah, if you want to check that out, I'm sure it's awesome,
but it's going to be its own kind of thing.
Yeah.
Yeah.
That's not funny, but you know what is funny?
What's funny?
Do while loops.
They're hilarious.
Do while loops are hilarious.
All right.
Describe what's going on in this picture without maybe the words here for us, Brian. People dancing at a party with somebody in the corner looking at them.
Yeah. So there's a couple, there's like a crowd of people dancing, having fun, just foot loose,
carefree, having a good time. And there's someone in the corner with a party hat and a drink,
but the most serious look on their face as if the world is about to end and the people in the
room don't know it. And the people in the room don't know it.
And the quote says, they don't know today.
I finally ran into a situation that required a do-while.
You're just going about it like life is normal.
And here it is, the do-while.
Do we have do-while in Python?
I was just thinking that.
I think no, but we have while else, which you could probably bend into some weird.
I don't know.
I don't really think you ever need to do while.
I don't know why languages have this.
Anyway.
Okay.
Amazing.
But it's a funny joke nonetheless.
Yeah, definitely.
So.
Nice.
Yeah.
Do you know what's not funny?
It's the end of the podcast. Oh? It's the end of the podcast.
Oh,
it is the end of the podcast.
I have to say goodbye,
Brian,
to everyone until next week.
Yes.
Until next week.
Thank you everyone for listening.
We,
we always appreciate it.
Thanks.
Bye.
Bye.