Episode Transcript
Transcripts are displayed as originally observed. Some content, including advertisements may have changed.
Use Ctrl + F to search
0:00
Hello and welcome to Python bytes where we
0:02
deliver python news and headlines directly to your
0:04
earbuds. This is episode 385 recorded
0:07
may 27th 2024
0:10
they get there right? Yeah, I am Brian
0:12
Auchin and I am Michael Kennedy This week's
0:14
episode is sponsored by mail trap more about
0:16
them later. If you want to connect with
0:18
us, we're all on Fostin
0:21
on the show and Michael and I
0:23
were fasted onions Pasta donians.
0:25
Yeah So those links are on
0:27
the show notes Also in
0:29
the show notes or at python bytes.fm
0:32
You can go to live if you want
0:34
to join us join the audience. Usually it's
0:36
Tuesdays at 10 a.m. Pacific
0:38
time You can also
0:41
use that link to get older videos too. If
0:43
you want to watch what watch what happens live
0:46
then finally if you'd like
0:48
to Receive an email
0:50
after a couple a day or two after
0:52
the show to find out all of the
0:54
links and And to have a
0:56
link to the show But make sure if you listen to this
0:58
and you want to make sure that you don't miss
1:01
any links and be able to go Check
1:03
those out later. You can become a friend
1:05
of our show and and we'll send
1:07
you those emails So you had announcement before we
1:09
get started? I do well I just wanted to
1:11
say Brian the reason that we're not just doing
1:13
this like a normal time We're just kind of
1:15
late and I got some messages from folks in
1:17
places like New Zealand like awesome This is a
1:19
perfect perfect time. So there's always a perfect time
1:21
somewhere in the world, but you've got this thing
1:23
going on tomorrow And
1:25
then for the rest of the week, I'm
1:27
going to the sink called the giant loop ride
1:30
This is off-road rally that's at
1:32
a hot springs Maybe
1:34
300 other off-road riders out in the southeast
1:36
desert of Oregon and riding the mountains and
1:38
the desert and open bar Live
1:41
music all sorts of shenanigans going on. Anyway, somebody
1:43
oh, yeah that that swimming pool is a hot
1:46
springs By the way, how crazy is that if
1:48
anyone is listening out there and it's also going
1:50
just come say hi That's all I'm saying but
1:52
also why we're doing this in the middle of
1:54
the night for some
1:56
places So I would
1:59
say If you have a podcast that kind of runs
2:02
late, sometimes it'll make you tired, wouldn't you think? You have
2:04
to rest a little? Yeah.
2:07
Let's talk about PostGrest, as in
2:09
PostGrest REST API. So this one
2:11
comes to us from Mark Little.
2:13
So thanks, Mark, for sending this
2:16
over. It's a good one. This
2:18
is basically a web
2:20
server, web front end for your database.
2:23
So you've got PostGrest, and you might
2:25
think, all right, well, I would just
2:27
like to expose the tables as endpoints
2:30
with ability to do
2:32
queries over HTTP endpoints. You can somehow
2:34
pass the query over. You want
2:38
to have security, things like that. So this is an
2:40
app that you can run, and it
2:42
automatically, with zero API work for
2:44
you, turns your PostGrest instance
2:47
into a somewhat
2:49
restricted API, basically.
2:51
Cool, right? Yeah. Now,
2:54
obviously, these things, I don't know, I always have mixed feelings
2:56
when I talk about these things. On
2:59
one hand, if you just say, I would like,
3:01
say, my view front end or something, or even
3:03
my Python code to just have access to the
3:05
database as an API, just read the crud things
3:07
of all the tables, you're good to go. This
3:11
is what you want, right? On the
3:13
other hand, sometimes I want to have more specific
3:15
things. Instead of just, here's the user table, I
3:17
want you to go through the create new user
3:19
API, a new user
3:22
API endpoint that uses, I don't
3:24
know, argon2 for memory hard, password
3:27
hashing and other checks. Every
3:30
time I come up against these things, I'm like, oh, they're really
3:32
cool, but at the same time, I
3:35
kind of want a little more specific control over
3:37
how it works. So if
3:39
you're just like, I just have a database, I just
3:41
want to be able to expose it real quick, let's
3:43
go, PostGrest, sort of thing. Cool, right? So
3:46
the way it works is it's written in
3:48
Haskell, which you may, and it's 4% Python,
3:50
so I guess there's a little Python in
3:52
there, but it doesn't really matter what it's
3:54
written in. It's just a thing you run,
3:56
and Then you talk
3:58
to it from your Python. From your javascript
4:00
or whatever it is. Okay, so there's a
4:03
a couple of things you care about. One
4:05
you probably care about performance. Ah, I'm not
4:07
super familiar the performance of Haskell, but I
4:10
believe it runs on top the Jv I'm
4:12
sorry if I get around by think so
4:14
which makes it pretty quick to zillow do
4:16
two thousand requests per second on the hook
4:19
who free tier which is pretty fast actually
4:21
I that's a pretty wimpy server and two
4:23
thousand requests? the second is pretty high end.
4:26
Three reasons for that: Haskell and as Britain
4:28
used in the Warp http server. A
4:30
Compiling compiled languages lightweight threads. I also
4:32
to him out warp so and Learn
4:34
but also to think it delegates as
4:36
much as it can to the database.
4:38
so it's like a really thin layer
4:41
over the database as I was describing
4:43
Socialize and J spawns and a son
4:45
response directly and sequel. Or as does
4:47
the data validation, the authorizations combining real
4:49
count and retrieve off on the to
4:51
post in a single. To me all
4:53
those different things are happening in the
4:56
database. not in this thing right Fps.
4:58
Finally it I used as the. Has
5:00
your instead of it's Sql sequel
5:02
is that ass Sql library which
5:04
means it's database connections are buying
5:07
a protocol for talking to it
5:09
and as stateless for horse on
5:11
skilling. Also very important for security
5:13
you don't want to just go
5:15
and the whole thing is read
5:18
right on. The internet is just
5:20
kill of little bobby tables and
5:22
find it still uses I Jason
5:24
web tokens and basically what you
5:26
do you create a user in
5:29
the database. And then he said
5:31
authentication like this user can only read
5:33
and they can only read these tables
5:35
are they come right at that table?
5:37
I don't know and then that's what
5:39
you can do when you authenticate over
5:41
this right? So basically leverages database users
5:43
in their room. implicit permissions to control
5:45
what you can do with a pie
5:48
is waste of version that a pie
5:50
which can enter seen as the database
5:52
changes you could keep it stable it
5:54
seems like and a document itself to
5:56
open a p I was x pretty
5:58
neat. so if you have a post
6:00
database you like that we really just
6:02
need rewrite of data and maybe even
6:04
an internal app and you just want
6:07
to have it resembled. check this out
6:09
and co co I didn't know that
6:11
turkey ahead of free to A anymore
6:13
but it is no less. So sick
6:15
Alice your back you know last the
6:17
maybe and from previous times a be
6:19
as a sad statement it must be
6:21
from previous times cause I have this
6:24
was updated a month ago but it
6:26
didn't I think that's are just whatever
6:28
that wnd free to was. that's. Giving
6:30
you a sense of what you
6:32
can do because cooking meat. I'm
6:34
gonna talk about a sink iowa
6:36
little bit but so there's a
6:39
desert go called the From take
6:41
a video on how Python a
6:43
Cinco Rick how Python a Cinco
6:45
works recreating from scratch. I'm in
6:47
a to a killer like this
6:49
this sir this idea because where
6:51
else love is ago but sometimes
6:54
it just feels magical into sort
6:56
of walk through some of the
6:58
some how it might might. Be
7:00
working in a in the background
7:02
is chemical so it goes through
7:04
ah, generate generators or view facts
7:06
about the amount lube Tux was
7:08
sleeping than yielding to await and
7:10
await. They think I'll end it.
7:12
Just kind of like the format
7:14
that this is written into. the
7:16
sort of get your get a
7:18
good mental model of how they
7:20
Cinco works. So this is some
7:22
and I guess if you're highly
7:24
recommend. This article was written looks
7:26
really fun, the colors and nice
7:28
to hate is Oregon's. Sucker for
7:30
good web pages he's read but
7:32
dumb but this is good. an
7:35
egg they skimmed it briefly were
7:37
already in like is chemicals. through
7:39
our we're facing works is exists
7:41
or spheres had to magical sometimes
7:43
but it is pretty magical and
7:45
at the heart of it as
7:47
generators shade so enraged themselves feel
7:49
super magical and on you can
7:52
understand how those where I can
7:54
assemble okay whoa that's hate and
7:56
a partition. the work in the
7:58
new just running in. It's
8:01
yes fragment of the generator Nazi go but
8:03
yeah it seems pretty wild is so can
8:05
walk through a little steps and then his
8:07
shows what the to has I felt the
8:10
final bit and then it rewrites the whole
8:12
thing in actually think I have so the
8:14
weekend see what it looks like and such
8:16
great along with that when I noticed the
8:18
links that some there was some camera go
8:21
from there was a comment also about if
8:23
you want to like learned a sicko from
8:25
trying to recreate or from scratch. There was
8:27
also a i do have easily talk from.
8:30
The From: I think it's from Fica.
8:32
Yep, I can India from Toy nineteen
8:34
I hadn't watched this. I still haven't
8:36
watched the Spurs my list. Now I'm
8:38
build your own A Sink. From
8:42
do Beasley awesome instructor services has
8:44
could videos was only will lead
8:46
to that I'm so some some
8:48
learning is Cinco are some good
8:50
stuff indeed What what else is
8:52
good is our sponsor Maelstrom All
8:54
right us Talk about of this
8:56
have said is sponsored by Mail
8:59
trap an email. Delivery platform that
9:01
developers love, an email sending solution
9:03
with industry best in Linux as
9:05
Ncp and Email A Pie as
9:07
well as as the case for
9:10
major programming languages and Twenty Four
9:12
Seven Human Support. Try for free
9:14
at the mail trap.i'll make you
9:16
think you mail traps. Let's move
9:19
on us and little higher order
9:21
salad Ryan Sir Perfect. Follow on
9:23
from what you are talking about.
9:25
A son Go parallel programming. It's
9:27
basically scales the waiting now. this
9:30
this is gonna be a dated statement
9:32
i believe but at the moment python
9:34
is not super good at doing computational
9:37
parallelism right but you know what is
9:39
gp use as the jeep use are
9:41
awesome at doing pillow programming so your
9:43
typical python program has one thread or
9:45
seen on t the most thing which
9:48
they have one thread he skelter seabees
9:50
maybe that sixteen my feeling were gaming
9:52
pc as that my him to macbook
9:54
pro a thing as ten thread You
9:57
know, there's way more it's get a
9:59
lot more work done if you scale
10:01
those out, right? But if you scale
10:03
their GPUs, they have sixteen thousand three
10:06
hundred eighty four threads things like that,
10:08
right? Incredible. Yeah, I
10:10
ran across this thing called
10:12
Bend be endy and
10:14
it comes from higher order company Which
10:17
has a couple of it's like a runtime for
10:19
Bend and then has been the language And
10:22
it's all about taking things and running
10:24
them in parallel and making them Basically
10:26
be Python so it says with bend
10:28
you can write parallel code for multi-core
10:30
CPUs and GPUs Without being a C
10:33
or CUDA respectively expert what ten years
10:35
experience and it feels just like Python
10:37
So they give us this example. Here's
10:40
a function called some not the best
10:42
example because it shadows a built-in but
10:44
whatever Let's get roll with it,
10:46
right? And so it
10:48
has def sum ticket depth and there's some
10:51
value that it starts with and then adds
10:53
them all up, right? So so sum all
10:55
the numbers from zero till two to the
10:58
end and to the depth right as a
11:00
switch statement that once it gets to
11:02
the end stops and then Sort
11:05
of recurses down as it would
11:07
and there's nothing that looks parallel about
11:09
this whatsoever But what
11:11
happens is this code actually runs
11:13
in parallel potentially on those thousands
11:15
of GPU cores Oh,
11:17
wow wild, right? Yeah, so
11:20
the way it does that is There's
11:23
a picture here Is
11:25
it breaks these things up into what are
11:27
called? Computational graphs
11:30
instead of work and then it just it
11:32
goes in processes them to see if it
11:34
if that part of the graph can be
11:36
parallelized Which is kind of
11:38
nuts? So you don't even
11:41
write the parallel code. It just looks at
11:43
your code You go so you that loop
11:45
that we just saw or that recursion type
11:47
of thing We just saw that actually could
11:49
be done recursively by just changing the parameters
11:51
or something, right? So pretty
11:53
wild and so yeah, they have
11:55
this HBM highly massively parallel runtime
11:58
that achieves near ideal speed as
12:00
a function across the available course. And then
12:03
Ben is the programming language that runs in
12:05
parallel powered by this thing. Looks
12:07
like Python. I don't
12:09
know how compatible, say, it's standard
12:11
library is or things like that. And
12:13
then you have this thing called kind, which
12:16
is a parallel proof checker. I have no idea about that. It
12:19
just says it's coming soon. So this is available on GitHub. And
12:22
you come over and you can find the language. And
12:25
guess what? It has 15,000 stars. I'd never even heard of it because
12:28
it's pretty popular. Written in Rust, not
12:30
that that's super relevant, but it's like
12:32
powers a language that looks like Python.
12:34
That's pretty cool. I'm cautiously
12:37
optimistic about that. It could
12:40
be good. So it looks
12:42
like the real implementation for it is here,
12:46
although it looks pretty short. I don't know.
12:48
I've dated it a couple days ago. But
12:50
here it says, I don't know. We'll have
12:52
to see how large of a
12:54
thing is it. I guess that's just some
12:56
pretty big scroll bars. So maybe the whole
12:58
run time is here. I mean, the number
13:00
of files might be lower, but could have tons
13:02
of stuff in there. Yeah, that's true. Anyway,
13:06
is it going to be a thing? I'm not sure. Maybe,
13:08
maybe not. But it's cool to see people
13:10
being creative with this kind of stuff. Yeah,
13:12
actually, it sounds pretty cool. I
13:17
guess simplify the way you get your code ready
13:19
for massive
13:21
parallel running. If it can just look
13:23
at your code and go, oh yeah, I got it. Yeah,
13:26
if it can look and say this is
13:28
what's often referred to as embarrassingly parallel, there's
13:30
like no state shared. You could
13:32
just take the pieces and break them up and run them on cores. Yeah.
13:36
If it just finds those automatically and does
13:38
that, which is what it claims to do.
13:40
Yeah, that's great. That's really great. Yeah, that's
13:42
really great. All right. Next
13:45
up, I've got a regular expressions.
13:47
So we're getting all sorts of
13:49
deep topics today. We are. We
13:51
sure are. I
13:54
ran across, I was looking at Reddit. And
13:57
so this Book is an older
13:59
book. The euro think it's year old
14:01
I'm scarred. the smartest way to learn
14:04
Python regular expressions and they don't know
14:06
really pets, other people's books or anything
14:08
on the show but I thought it
14:10
was kinda nice that it's a lean
14:13
pub thinks his. third they're doing their
14:15
own thing and his for get into
14:17
i think this can the but the
14:19
minimum price is free so is in
14:21
since they're allowing their own preserve a
14:24
to to throw few bucks array of
14:26
thing is they can because when had
14:28
it's good to have people. Teaching things
14:30
you I ran across on
14:33
Reddit. And or
14:35
the topic sound nice others to go
14:37
through an induction, a regular expressions they
14:39
do an application, a taco puzzle, learning
14:42
and stuff and then I skimmed the
14:44
rust belt. Looks like great stuff and
14:46
as a is some Python related thing
14:48
to teach regular expressions as group would
14:51
be good. And then I went watch
14:53
the video and I'm even more intrigued.
14:55
So the idea on this book is
14:58
that modern ways to learn or difference
15:00
in possibly. People my age might be
15:02
used to have just reading a book
15:04
and trying things out, but this is
15:07
this is set up visible video introduction
15:09
to the book. They're using the book
15:11
itself as a as a long form
15:13
teaching people but it's also. There's a
15:16
video is a video course attached to
15:18
his of you. but if Lake Erie
15:20
gets a book in your intrudes, there's
15:22
links to the different course chapters within
15:24
the book which is Kevin the idea
15:27
and then ah there's there's puzzle solvers
15:29
for each. each senior learning single
15:31
apply it in a puzzle environment
15:33
and they're using a thing called
15:35
as sin sinks tour at says
15:38
so awful name honestly i think
15:40
but if i nxt are but
15:42
dub but it looks like there's
15:44
a whole bunch other people using
15:46
a to and i've never tried
15:48
it but it's has some an
15:50
online trying as from code platform
15:52
i think so i'm i'm i'm
15:55
a i'm gonna try this out
15:57
omg i'm curious about the the
15:59
whole idea of reading a book
16:01
and clicking on it and doing that
16:03
as well. Yeah. That's, you
16:05
know, mileage very, very for me because I'm probably
16:07
going to download this onto a Kindle and I
16:09
can't collect on anything with the Kindle,
16:11
but at least the one I'm using. But
16:14
anyway, might be fun to go through. So. Yeah.
16:18
Looks excellent. Excellent. Give us a
16:20
report when you get back. Sure. Yeah. See
16:23
how it went. Yeah. And, you know, not
16:25
enough regular expression material out there for just
16:27
deep, diving deep and really getting to getting
16:29
your head around it. So yeah, they're very
16:31
powerful if you're good at them. Yeah.
16:35
Big if. Those
16:37
are items. Do we have any extras?
16:39
I have one that's quite interesting and
16:41
I don't, somebody gave me
16:44
a bit of a tip towards this. I
16:46
don't remember who it was. So I think it was
16:48
a massadon, but thank you. And
16:51
sorry about forgetting who the credit
16:53
here on Wikipedia. We have the
16:55
Python conference, aka PyCon. And
16:58
what does it say about it? The Python
17:00
conference, also called PyCon, is the largest annual
17:02
convention for the discussion and promotion of the
17:04
Python language. Scroll down a little bit, Ryan.
17:07
See things like where was it in 2003?
17:10
It was in DC. Had 200 attendees. 2012
17:13
was in Santa Clara. Oh,
17:16
2016. Yeah, baby. Portland. Almost.
17:21
Almost. The record. Almost. Almost.
17:26
Almost. Almost. Two
17:31
more people beat that number, came
17:34
over that number from Cleveland, Ohio
17:36
in the before days. And
17:38
then COVID hit, knocked
17:40
it down and slowly building back. Like in
17:43
Pittsburgh, it was up to 2,500 again. So
17:47
what was that? It's still got
17:49
about 50% more to add or a
17:51
third looking backwards. It's down.
17:54
That's not what I want to talk about. I Want to
17:57
show you what is in this Wikipedia table right below
17:59
it. The next the Long
18:01
Beach be going to California. Let's go
18:03
going to the Beats gonna some warm
18:05
weather, go into a vacation spot. I
18:08
will bet you that this significantly beats
18:10
ah those numbers and because it's just
18:12
a destination Ip wanted to go there
18:14
to be there. a lump on lieutenant
18:17
I sit in the west coast. I
18:19
mean nothing is Pittsburgh but it's only
18:21
two hours away from such from or
18:24
was it cleaver Cleveland via an south
18:26
we did of Salt Lake City in
18:28
their the In Terms mission. Times with
18:30
Salt Lake City was still under a
18:33
lot of funk like was the first
18:35
one that came back and person after
18:37
covert so it it was kind of
18:39
funky. I went to the Twenty Twenty
18:41
Three one. I know that in the
18:44
i'm a a a Summer's gone the
18:46
record as saying it thinks it like
18:48
there's a lot more cool destination things
18:50
doesn't they Some places on the coasts
18:52
yeah and Midwest obviously but but think
18:55
doing it can the middle of the
18:57
country make sense of the people can
18:59
get. easy flights from anywhere in
19:01
the country to san by us and
19:03
a what are you optimizers for are
19:06
you i try to move it around
19:08
are you trying to make it as
19:10
centrally located a tiny make it as
19:12
cheap as possible he tried to make
19:14
it a destination all these different things
19:16
play into this and this is the
19:18
biggest funding for the ps f so
19:21
it's it's not just like a curiosity
19:23
right it it is the funding for
19:25
the pss to a significant degree is
19:27
interesting though the portland was way back
19:29
and twenty seventeen and this in twenty
19:31
twenty six as can be than next
19:33
time that it's gonna be on the
19:36
west coast i don't think that i
19:38
know that everybody in the east coast
19:40
thanks to salt lake is in the
19:42
west boots not really since nine the
19:44
same time zone brain sometimes smelled i
19:46
am pacific time let's go against anyone
19:48
is my access argot planned tentatively pipe
19:51
that python after pittsburgh's so next yourself
19:53
as wearing it's and round to but
19:55
then long beach california and i'm i'm
19:57
here for a brain also over always
19:59
me I'm curious about the numbers
20:01
of how many people showed up in
20:03
Montreal. It's cool
20:06
to see you can just look it up on Wikipedia. Yeah, it's
20:08
all right here. I've got
20:10
something completely random that I... Prince
20:16
of Persia was a video game from 89. I remember it. Oh,
20:20
not only was it a video game, it was
20:23
one of the best video games. It was so
20:25
good. Yeah, it was one of these cool racers
20:27
through all sorts of stuff. We
20:30
had a little runner thing and had to jump
20:32
over all sorts of stuff. It was a fun
20:34
game. And then there was a bunch
20:36
of different permutations of it.
20:39
And it's still going strong, I think. Still
20:42
stuff going on. Anyway,
20:44
a cool game, but I
20:47
ran across this. There's a book about it. So
20:50
Jordan Meckner is a person
20:52
that wrote it and originally
20:55
wrote the Prince of Persia game.
20:58
And he wrote a book called
21:01
Replay. It's a memoir of an uprooted
21:03
family. And apparently,
21:06
it goes back to 1938
21:08
when somebody in his
21:11
family, his parents
21:13
fled Austria to escape
21:15
the Nazi persecution. And
21:18
then they traveled to the US. Eventually,
21:20
they went to France. And then they
21:23
went to eventually... I think. Actually,
21:25
I'm just making this up. I don't know if
21:27
he ever made it to the US. I
21:29
think so. But then
21:32
he goes back eventually. Yeah,
21:34
because he goes back eventually
21:36
and works in France for
21:39
a little while. And
21:41
then this book about his life, his
21:43
family, and his life story, and about
21:45
the Prince of Persia. So I'm kind
21:47
of excited to read this. I
21:50
really like these looks inside the storytelling
21:52
of the history of some of these
21:55
famous games and famous platforms. Yeah,
21:58
they're very interesting. Yeah. The
22:00
day I wrote the like wrote the
22:02
music for for this of the original
22:04
video. Okay, is Chemical on a Runner
22:06
as sick as a new one of
22:09
them and of the older computers than
22:11
it is? so that's it as my
22:13
extra saw some. Let's close it out.
22:15
What? they. Were. Can't
22:18
joke at in a way cause
22:20
brain to We have this woman
22:22
developer said in hair pretty happy
22:24
and this boss comes in managers
22:26
as I don't like this bash
22:29
script you created. Brian Python instead
22:31
commands the boss imports a process
22:33
so process call worked out sh
22:35
well that's a day's work done.
22:39
A face at a half ads as
22:41
if you want me to write my
22:43
phone call is going from Python Moscow
22:45
Yeah good. Wouldn't have one of the
22:47
time sir. Mike Wary Early on earth
22:49
is not earlier. they were twenty
22:51
years ago so I'm I'm a
22:53
spy myself for a new job
22:55
and they've got all these builds
22:57
make script servers for C plus
22:59
plus codes and a camera. There
23:01
were there in their batch files
23:03
and in fashion all sorts of
23:05
stuff and in his had guinea
23:07
worm reread this cause is kind
23:09
of a mess so I rewrote
23:11
it in a combination of i
23:13
had have combination of bash pearl
23:15
python said whole bunch of things.
23:17
Whatever it wanted to to to
23:19
what I saw was an elegant
23:22
solution and the team was horrified
23:24
near like we're not learning that
23:26
me like images of my okay
23:28
so i rewrote role in python
23:31
and that was of for semi
23:33
I really grabbed Python for do
23:35
whatever I want as a shell
23:37
scripts language to go yeah limits
23:40
to suppress com said process that
23:42
cause shape and nice a don't
23:44
we've heard complaints that ago. After
23:48
Mothers' where I didn't hear no error handily
23:50
needed let's those his letter read Now it's
23:52
a good job and that comes we're Credit
23:54
Where credit's you. That comes from linux. And
23:57
book Linux Him witness to Twelve Six Michael
23:59
from another one. Watson as
24:01
always. Thanks everyone! To look
24:03
for listen,
Podchaser is the ultimate destination for podcast data, search, and discovery. Learn More