WEBVTT

00:00:00.001 --> 00:00:03.900
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to

00:00:03.900 --> 00:00:11.380
your earbud. This is episode 272, recorded February 23rd, 2022. I'm Michael Kennedy.

00:00:11.380 --> 00:00:12.340
And I'm Brian Okken.

00:00:12.340 --> 00:00:14.140
And I'm Calvin Hendryx-Parker.

00:00:14.140 --> 00:00:16.400
Hey, Calvin. So good to have you here.

00:00:16.400 --> 00:00:17.260
I'm excited to be back.

00:00:17.260 --> 00:00:20.700
Yeah, it's great to have you back. I also want to say this episode is brought to you by

00:00:20.700 --> 00:00:25.160
Fusion Auth, a new sponsor. Thank you so much to them for supporting the show. Check them out at

00:00:25.160 --> 00:00:29.980
pythonbytes.fm/fusionauth. More on that later. Calvin, it's been a while.

00:00:29.980 --> 00:00:34.520
Since you've been here, but you're a frequent guest. How about just tell quickly people about

00:00:34.520 --> 00:00:40.820
yourself? Sure. I've been a almost, I guess, nearly lifelong Pythonista at this point. I'm going back

00:00:40.820 --> 00:00:46.180
a long ways, but started a company back in 1999 called Six Feet Up, where I am the CTO and co-founder.

00:00:46.180 --> 00:00:51.300
And we are all things Python and all things cloud. So we're doing some cool stuff there. I've been

00:00:51.300 --> 00:00:56.660
very involved in some open source projects, like the Plone Foundation for the Plone CMS. We're very

00:00:56.660 --> 00:01:02.180
involved in Django as well. I'm sponsoring the Django Software Foundation. So super excited to be

00:01:02.180 --> 00:01:06.540
involved in open source and all things Python. Right on. So if I was a company, a person said,

00:01:06.540 --> 00:01:10.260
I need a Python app, I need some help with it, or maybe someone to even build it, I might reach out

00:01:10.260 --> 00:01:14.240
to you all and you might build it for me. Yeah. No, we'd love to talk about those kinds of opportunities.

00:01:14.240 --> 00:01:18.820
The harder and more challenging, the better. Yeah. Those are the fun ones. Yeah.

00:01:19.620 --> 00:01:28.200
I agree. I completely agree. I like easy. All right. Well, I think this one you got here and this

00:01:28.200 --> 00:01:32.260
for the first one, Brian, maybe not so easy. That's what's up with your mocking. Why is it not working?

00:01:32.260 --> 00:01:39.880
Well, your mocks. So this is a great, actually, this is a rabbit hole, but well, mocks are a rabbit hole.

00:01:40.140 --> 00:01:47.980
So Ned Batchelder, great guy wrote, he writes a lot of great stuff. Also maintains coverage.

00:01:47.980 --> 00:01:56.380
But he wrote an article called Why Your Mocks Still Don't Work, which is a reference to an earlier

00:01:56.380 --> 00:02:04.720
article he wrote called Why Your Mock Doesn't Work. And he wrote that in 2019. So if you haven't read this

00:02:04.720 --> 00:02:09.340
first, so I'm going to go back and recommend both of these. So Why Your Mocks Don't Work,

00:02:09.340 --> 00:02:17.440
or Why Your Mock Doesn't Work, is an excellent article. It starts talking about just like,

00:02:17.440 --> 00:02:24.640
well, to think about how mocks work, you really have to understand Python name spaces and names and how

00:02:24.640 --> 00:02:30.480
imports work and all of that stuff. And maybe you don't think you should have to, but you kind of do.

00:02:30.480 --> 00:02:38.060
So in imports, those are not entirely obvious, like the way that that happens compared to other

00:02:38.060 --> 00:02:42.380
languages, right? Where you just say, I'm using this library. There's like, it's way more direct.

00:02:42.380 --> 00:02:47.880
So Ned starts off with like this really great example of just basically two variables,

00:02:47.880 --> 00:02:54.220
X and Y pointing to a number. And if you assign into each other, but you don't really point at another

00:02:54.220 --> 00:02:59.680
variable. You point at the thing that the variable is pointing to if you assign X to Y or Y to X or

00:02:59.680 --> 00:03:06.020
something. And this hat, this does have to do with importing because the names that you import are

00:03:06.020 --> 00:03:12.620
just kind of variable names that point to something. So he talks about namespaces and, and where, where

00:03:12.620 --> 00:03:18.540
things point to talks about importing and the difference, mostly the difference between from,

00:03:18.540 --> 00:03:27.000
from foo import thing instead of import foo and reference it as foo thing. Those are completely different

00:03:27.000 --> 00:03:34.640
names within, within your Python application. So talk walks through that, talks about it and why.

00:03:34.640 --> 00:03:42.800
So if you've got a value from one module pointing to an original value and then another one pointing to

00:03:42.800 --> 00:03:49.740
the same threat thing, if you mock the wrong place, you're not going to get what you think is right.

00:03:49.740 --> 00:03:56.980
So basically, and this is terrible to discuss over podcast. So I recommend looking at this,

00:03:56.980 --> 00:04:04.620
because it's a really great example of how mocks work and, and why, why they act the way they do.

00:04:04.620 --> 00:04:08.540
And you'll, you'll be able to fix a lot of your problems. So this is a good recommendation,

00:04:08.540 --> 00:04:14.320
but the one that we're trying to talk about right now, why your mocks still doesn't work has to do with

00:04:14.320 --> 00:04:21.980
this cool decorator thing that mock. I don't remember when a unit test mock added this, but there's a patch decorator.

00:04:21.980 --> 00:04:27.820
Actually, I'm going to link to the show notes somewhere. We talk about the patch decorator and

00:04:27.820 --> 00:04:34.040
it's, it's pretty neat. Actually, I'm jumping all around. Sorry. But if you just say like patch

00:04:34.040 --> 00:04:41.920
something, what happens on your test? Like in this example, he's got two, you got a patch, cool feature

00:04:41.920 --> 00:04:50.680
cool feature dot logger. And you're not patching it with anything with this decorator. What happens is

00:04:50.680 --> 00:04:57.400
you're, you get these like other variables that you can add as parameters, mock prep and mock logger

00:04:57.400 --> 00:05:03.560
that you can use those to change it. You can change the behavior, the, you can use asserts on it. You can

00:05:03.560 --> 00:05:10.240
change the return values on these through that. It's a, just a, this is a way to get a handle into your

00:05:10.240 --> 00:05:17.240
mock object. It's pretty cool. and, but the trick is they have to be in the right order.

00:05:17.240 --> 00:05:22.400
And this example looks like it's fine, but you've got logger at the bottom decorator,

00:05:22.400 --> 00:05:29.120
which is really the first and prep as the above decorator. And it's the, it's the first one,

00:05:29.120 --> 00:05:33.080
Brian, it says the first line says this prep one. The second one says logger.

00:05:33.140 --> 00:05:39.860
Yeah. But that's not the way it happens. So the catch here and the punchline is, it goes,

00:05:39.860 --> 00:05:45.620
but when you're reading decorators, it goes bottom up, and, left to right.

00:05:45.620 --> 00:05:46.300
Like onions.

00:05:46.300 --> 00:05:47.540
Sure.

00:05:47.540 --> 00:05:52.900
Right. Like there's layers around your code and like the inner layers, the first one it sees.

00:05:53.140 --> 00:05:58.320
The second, so if you, the way he has it originally written, it just fails. It doesn't work.

00:05:58.320 --> 00:06:05.400
the second punchline is unless you've got a real good reason to use, auto spec because auto spec

00:06:05.400 --> 00:06:11.200
would have caught this problem like right away. And, what auto spec does is it says the thing that

00:06:11.200 --> 00:06:16.600
you're mocking, you have to call it with the same interface that the thing had in the first place.

00:06:17.140 --> 00:06:24.880
and, so if you've got a, a class or a module that has a function in it, you can't call

00:06:24.880 --> 00:06:30.800
other functions. Whereas normal mocks, you can call whatever you want. so the default is free

00:06:30.800 --> 00:06:36.180
for all. What you really should do is auto spec equals true. And really a lot of people, me included,

00:06:36.180 --> 00:06:41.880
wish that that was the default to begin with, but for historical reasons, it can't be because it

00:06:41.880 --> 00:06:48.100
would break other stuff. But anyway. Yeah. Yeah. if it's not the default to start with,

00:06:48.100 --> 00:06:54.200
if you put that in to say now only behave as if you are the thing that I say you're pretending to be,

00:06:54.200 --> 00:06:58.720
that's going to crash a ton of stuff. Yeah. So, yeah. And then the third and final punchline is,

00:06:58.720 --> 00:07:09.060
uh, just don't use mocks. even he Brent mentions it in both articles, avoid using mocks if you can.

00:07:09.060 --> 00:07:14.020
So absolutely. Felix out in the audience says tiny feature with a lot of power, this auto spec.

00:07:14.020 --> 00:07:19.020
Yes. Very much like Yoda would put it. I love it. All right. What do we got next? Calvin thoughts on,

00:07:19.020 --> 00:07:24.700
on mocking real quick before we move on. I'm, we are just diving into that and I don't do a lot of

00:07:24.700 --> 00:07:31.040
the test work myself. So I'm sure Brian is the super expert on all things, by test, of course. So

00:07:31.040 --> 00:07:36.840
I don't have a huge opinion here on specific mocking. Although I think it is important for folks to

00:07:36.840 --> 00:07:42.300
realize that, yeah, decorators go from like that closest to the function out. It was an important,

00:07:42.300 --> 00:07:48.240
uh, call out there. Yeah. The other one was from thing import something. And then you patch the thing

00:07:48.240 --> 00:07:51.820
inside there. It's kind of that, that I actually, that was news to me. That's very interesting.

00:07:51.820 --> 00:07:56.800
All right. Also news to me, please, please tell me about this. Chris may thank you, Chris may for

00:07:56.800 --> 00:08:04.200
sending this over and wow. I don't know if you've heard about please folks, PLS as an LS

00:08:04.200 --> 00:08:10.360
replacement for Linux and macOS, but wow, this thing is cool. was this, had either of you heard

00:08:10.360 --> 00:08:15.080
about this? Not until today. And I went and installed it as part of my demo so I could see it because it

00:08:15.080 --> 00:08:19.780
looks pretty darn awesome. So this is an LS replacement and I know there are other LS replacements

00:08:19.780 --> 00:08:25.080
that already exists. So you can do more things, but this is a developer focused one written in Python.

00:08:25.080 --> 00:08:31.860
That's pretty darn awesome. So if you go look at the image I linked to, or just go check out the site,

00:08:31.860 --> 00:08:40.080
you can see that if you say, so I've alias LS to PLS. And if I just say LS, it shows you the contents of

00:08:40.080 --> 00:08:47.400
your directory folders on top. And then it has icons for the types of files that they are. So I did an LS,

00:08:47.400 --> 00:08:52.400
there's a Git ignore. So it has a Git branch icon. There's a license with the law. There's a markdown

00:08:52.400 --> 00:08:57.440
file. There's a Python file, the Python logo, but it goes beyond that. Like it understands your Git

00:08:57.440 --> 00:09:04.140
ignore and the files that are considered hidden are the Git ignored ones as well. And it won't show you,

00:09:04.140 --> 00:09:11.480
even if you do like a hidden file listening, it won't show you things like the .es underscore store

00:09:11.480 --> 00:09:17.800
on macOS because that's in the Git ignore. So the structure that it gives you is related to that.

00:09:17.800 --> 00:09:23.000
Also for Python, if you have a virtual environment, it'll treat that directory as hidden. And because

00:09:23.000 --> 00:09:29.220
the directory is hidden, like it's sort of suppressed in its visibility. So there's really cool features

00:09:29.220 --> 00:09:35.400
around this that have to do with basically saying, all right, you're a developer, you're listing files

00:09:35.400 --> 00:09:41.980
that are probably developer like. Now what, now what do we do? So another part that's cool is you can do

00:09:41.980 --> 00:09:48.860
and please --details, which I alias to L because that's the LS like equivalent. And in this

00:09:48.860 --> 00:09:55.820
world, it shows you the same types of things, but it also shows you the size in the human terms. So

00:09:55.820 --> 00:10:00.140
instead of like one zero one, one, one, two, one, one, seven, one, one, one, two, it would say that's

00:10:00.140 --> 00:10:05.860
10.2 gigabytes, which is nice, but it also shows you the Git status in the listing. So like it has a dash

00:10:05.860 --> 00:10:09.720
M next to a file I modified and so on. What do you all think of this?

00:10:09.720 --> 00:10:16.820
I think it's excellent. The, I tried to use it and failed and you've helped, helped me understand why,

00:10:16.820 --> 00:10:21.800
because you, it has, you have to have fonts, it's like some special fonts installed, right?

00:10:22.120 --> 00:10:28.140
So one of the questions when I posted this week was people like, how does it have custom icons?

00:10:28.140 --> 00:10:33.520
What magic is this? Cause this will work over, like if I SSH into somewhere and install please on the

00:10:33.520 --> 00:10:38.140
server, as long as my local terminal is set up correctly, this will work. And like, how does this

00:10:38.140 --> 00:10:43.920
work? Well, the way it works is you have to have your terminal font set to a nerd font. So I've talked

00:10:43.920 --> 00:10:50.720
about nerd fonts before, but all these nerd fonts have all these special icons in them. And long as your

00:10:50.720 --> 00:10:55.440
active terminal font is one of the nerd fonts, then you get all these cool behaviors. If you don't,

00:10:55.440 --> 00:10:58.180
you get squares, which are less than awesome.

00:10:58.180 --> 00:11:05.200
My only complaint with it is that I wish it would have emulated more of the flags from standard LS

00:11:05.200 --> 00:11:10.720
so that it just kind of work a light. I installed it. The first thing I did was like, please dash AL

00:11:10.720 --> 00:11:13.860
and I got like a no, no L flag.

00:11:13.860 --> 00:11:14.580
We don't know what that is.

00:11:14.580 --> 00:11:15.660
Yeah. I didn't know what that was.

00:11:15.660 --> 00:11:20.040
Yeah. It's kind of its own thing. That's why I did the alias on it. And I'm like, okay, well,

00:11:20.040 --> 00:11:25.260
I'll just, I'll do these things. Another thing that's interesting, it has a, you can set up these,

00:11:25.260 --> 00:11:32.560
these YAML configuration files that control how it looks. And then you can put those kind of like

00:11:32.560 --> 00:11:37.460
node JS does with node modules. Like you can put it at different or the project.json, you can put it at

00:11:37.460 --> 00:11:43.660
different levels. And if you go into a certain project that you had of a configuration file in

00:11:43.660 --> 00:11:48.840
there somewhere, it'll pick up that configuration and then use that to like customize how it looks

00:11:48.840 --> 00:11:51.520
for those. So that's kind of an interesting thing as well.

00:11:51.520 --> 00:11:56.740
That is awesome. I mean, we need more, we need more like fun stuff in our terminals as developers.

00:11:56.740 --> 00:12:02.700
I totally love this. This is absolutely the way to get people hooked on using the terminal in the

00:12:02.880 --> 00:12:07.600
console. Yes. And I was thinking about like server management, which we'll get to later,

00:12:07.600 --> 00:12:13.480
right, Calvin? Yeah. Yeah. But if you want to go into the server and so I'm going to SSH in and do a

00:12:13.480 --> 00:12:19.180
thing like this is your entire user interface. Yeah. To that. Sure world. And so, yeah, yeah,

00:12:19.180 --> 00:12:24.900
this is your world. So this is a way to bring like a little bit more UI information rather than just raw

00:12:24.900 --> 00:12:31.060
white text listing a files. I feel like there's like actually a lot of value in this. Oh, totally.

00:12:31.060 --> 00:12:37.140
Awesome. Let's see a Dean out in the audience and former. Yes. I thought my life was complete until

00:12:37.140 --> 00:12:43.720
today. I didn't know this was missing from my life, but it is. Yes. Please more terminal stuff.

00:12:43.720 --> 00:12:50.740
Absolutely. Well, speaking of more terminal stuff. Yeah. Speaking of more terminal stuff. Yeah. Take it away.

00:12:51.360 --> 00:12:57.140
All right. So we over at six feet up, we've been very focused on the developer experience. And so

00:12:57.140 --> 00:13:02.040
once a week we get together and talk about just, we can do a called code review, but it really,

00:13:02.040 --> 00:13:07.240
it's more of a show and tell. And this is something I showed off last week at our code and review and

00:13:07.240 --> 00:13:13.400
show and tell, which is a terminal that is GPU based and written in Python. And it's called Kitty.

00:13:13.400 --> 00:13:20.340
If you've not used it, it actually is a super awesome, super fast. Basically, I don't know. I found it to

00:13:20.340 --> 00:13:25.340
just be a super smooth experience. And the reason I had revisited it was I'd been using Tmux forever.

00:13:25.340 --> 00:13:30.300
And before that I was using screen and I wanted to like, just have the ultimate power tools available

00:13:30.300 --> 00:13:35.940
to me as a, as a developer. And as a, like my primary mode of operation is basically hanging out

00:13:35.940 --> 00:13:40.780
in the shell or an editor all day long. So I want the best tools possible. So I'd highly recommend

00:13:40.780 --> 00:13:46.340
folks check out Kitty. It is absolutely tuned for performance. And you may ask, well, why the heck would

00:13:46.340 --> 00:13:51.840
I want a GPU enabled terminal is just showing me text is because I want the most performance

00:13:51.840 --> 00:13:55.840
possible out of my, my system when I am using it. And so I actually was going to give a quick

00:13:55.840 --> 00:14:01.800
little demo here of Kitty. This is actually using PLS. And obviously, yeah, I see it.

00:14:01.800 --> 00:14:03.100
I have the right.

00:14:03.100 --> 00:14:06.720
And what is this? Oh, my, is this on my posh also? What do you got for the,

00:14:06.720 --> 00:14:10.460
Oh, for the bullet train down there. So it's actually bullet train core.

00:14:10.720 --> 00:14:16.360
it's not maintained anymore. That's probably my next, my next venture is going to be replacing

00:14:16.360 --> 00:14:21.380
that line with some new or something like that. Exactly. Some new, you know, system for showing

00:14:21.380 --> 00:14:26.760
my awesome, like prompt up there. But yeah, if you get the right fonts installed and all that Kitty

00:14:26.760 --> 00:14:32.720
supports all that stuff seamlessly, it's very, very fast. And one really cool thing, since we're all

00:14:32.720 --> 00:14:38.020
like Pythonistas and people who are listening to this would totally relate. You can extend Kitty

00:14:38.220 --> 00:14:44.440
with kittens that are basically Python plugins for Kitty. so if you actually, I'll, I'll give

00:14:44.440 --> 00:14:48.680
you a quick example. So if I run Kitty, I, it is, I love, but I love it. I kind of love it actually.

00:14:48.680 --> 00:14:54.460
So you just, you invoke Kitty with the kitten flag and say like what kitten you want to use. In this

00:14:54.460 --> 00:15:01.500
case, I'm going to use iCat. I'm going to just basically echo out a Slack emoji that we use for Python.

00:15:01.500 --> 00:15:07.860
Oops. Oh, oh no. Is this like going to be like the, total like demo guys, not, not being very kind

00:15:07.860 --> 00:15:08.280
to me now.

00:15:08.280 --> 00:15:13.860
I love that your, your prompt has the Python version and stuff in there. That's great.

00:15:13.860 --> 00:15:18.960
Oh yeah. If you're in a specific like pyenv area, it definitely shows up. Let me just,

00:15:18.960 --> 00:15:24.420
let me just like try it here. iCat Python. Oh, there we go. So I must've just been in the wrong

00:15:24.420 --> 00:15:29.120
directory, but so you can actually show graphics on the screen. So if I want to look at an image real

00:15:29.120 --> 00:15:33.640
quick, I don't need to go to finder and open up preview and like do a quick look on an image.

00:15:33.740 --> 00:15:38.100
I can actually like, you know, quick look on any image I want. And I, one of the things I did want

00:15:38.100 --> 00:15:42.620
to show off, I go back to the director. I was, people who are listening, this looks like a full

00:15:42.620 --> 00:15:48.380
high res image in the terminal. Yeah. Based on a PNG. So I used iCat, which is a kitten to display an

00:15:48.380 --> 00:15:52.840
image directly in the terminal. And now if I wanted to do show even something coolers, because one of the

00:15:52.840 --> 00:15:57.620
features of Kitty is it's basically got a graphic subsystem in here. And if I wanted to like, look at my

00:15:57.620 --> 00:16:02.720
markdown files, normally if I'd use bat to look at my markdown, like for the readme that's in here,

00:16:02.720 --> 00:16:08.600
you know, you get the kind of content highlighted markdown, kind of cool, not, you know, not super

00:16:08.600 --> 00:16:14.440
great. But if I do MD cat, which is Kitty enabled, it actually leverages the Kitty subsystem here.

00:16:14.440 --> 00:16:22.340
I can actually review my markdown file with images in line. So you can see that the XKCD cartoon is

00:16:22.340 --> 00:16:27.300
actually embedded into the readme of that document. And it does a little better job of like coloring and

00:16:27.300 --> 00:16:31.440
highlighting the syntax. So if you want to preview markdown documents without again, not going to

00:16:31.440 --> 00:16:36.040
preview or not going to like rendering it to HTML and viewing your browser, you can actually view it

00:16:36.040 --> 00:16:42.420
right in your terminal with the images shown in line, which is super awesome. And one last thing,

00:16:42.420 --> 00:16:48.540
one more trick I'll show you. There is a Kitty kitten for viewing diffs in a rich tool. So if I do

00:16:48.540 --> 00:16:56.300
get a diff tool, I've configured with my, you know, dot get config to configure an alternate diff tool for

00:16:56.300 --> 00:17:02.560
diff. And now I get this really beautiful, you know, high res graphic representation of my diff,

00:17:02.560 --> 00:17:07.000
my files. So really kind of pretty, you can see there's two, two diffs, two different files,

00:17:07.000 --> 00:17:11.960
I can page through the different files and it shows me, you know, side by side, you know, diffs.

00:17:11.960 --> 00:17:13.020
Is that still in the terminal?

00:17:13.020 --> 00:17:15.300
That is still in terminal. I did not leave my terminal.

00:17:15.300 --> 00:17:16.540
It looks like a new window.

00:17:16.540 --> 00:17:19.880
It did. It looked like a new window, but it's actually all in terminal. So you can stay in

00:17:19.880 --> 00:17:25.760
your terminal, stay at your keyboard and all the, all the shortcuts are super nice. One last thing.

00:17:25.760 --> 00:17:32.300
The diff just sold me. So yeah, you can split your windows, obviously like, you know, other kinds of

00:17:32.300 --> 00:17:37.880
terminal emulators, like if you're using Tmux, but then it's got all the layouts built in. So if I

00:17:37.880 --> 00:17:43.660
wanted like horizontal or vertical or a grid, or if I wanted to like, just get to the current one I'm on,

00:17:44.300 --> 00:17:49.140
you've got all that available to you with nice shortcut keys and you can just, I got rid of Tmux and

00:17:49.140 --> 00:17:51.140
started just going all in on kitty only.

00:17:51.140 --> 00:17:55.920
Okay. I got a question. So I've always been confused about this whole windowing thing because

00:17:55.920 --> 00:17:59.600
I just opened another terminal. so.

00:17:59.640 --> 00:18:04.480
Oh, Oh, I see what your question is. I don't want to open another terminal. I don't want to reach for my

00:18:04.480 --> 00:18:09.980
mouse when I have to like go between terminal windows. So I'd rather have like multiple tabs and then have

00:18:09.980 --> 00:18:14.860
splits. And so I can have like a paging going on in one window or another window. I can like, you know,

00:18:14.860 --> 00:18:18.980
then edit these things, make them like shorter or taller or split them in a different way.

00:18:18.980 --> 00:18:24.440
So I feel like just keeping my hands on a keyboard keeps me more productive as a developer,

00:18:24.440 --> 00:18:29.020
as opposed to reaching over for the mouse. I know it's not that far away, but I feel like it breaks

00:18:29.020 --> 00:18:33.780
that flow. If you're, you're typing away at code and you want to like quickly, like open up a tail

00:18:33.780 --> 00:18:38.740
for a log and like a same window right below where you're running the process. You're just,

00:18:38.740 --> 00:18:41.220
you know, a couple of keystrokes away and you've got that open and going.

00:18:41.320 --> 00:18:47.080
Cool. Nice. Yeah. Yeah. Oh, that's really cool. So I know we're not to the joke section yet,

00:18:47.080 --> 00:18:50.740
but you know, the joke about how do you generate a random string, put a new computer science

00:18:50.740 --> 00:18:57.820
student inside of them and ask them to exit. Yep. So I think the new version is put four of them in

00:18:57.820 --> 00:19:01.820
these different panes controlled here and ask them to exit the top right one.

00:19:01.820 --> 00:19:04.160
Here, I'll do it right now.

00:19:04.160 --> 00:19:07.260
Even more random number or word.

00:19:07.260 --> 00:19:08.720
There we go. Boom. Did it.

00:19:10.840 --> 00:19:12.560
I'm going to try kitty. This looks great.

00:19:12.560 --> 00:19:17.460
It's super configurable. It supports all the nerd fonts, all the color schemes. I've got,

00:19:17.460 --> 00:19:20.820
you know, just got, there's a bunch of cool plugins for it. I've got a search plugin,

00:19:20.820 --> 00:19:25.040
which searches through your back through your terminal. And so if I was, there's nothing in

00:19:25.040 --> 00:19:31.000
that specific one, but if I searched through here and wanted to search backward, it uses FCF to do

00:19:31.000 --> 00:19:35.980
searching backwards. So if I was looking for like LS, you see it highlighted the word LS or 2020.

00:19:35.980 --> 00:19:39.520
And then if I had multiple ones and I could just arrow back up between them.

00:19:40.360 --> 00:19:41.400
So it's all built in.

00:19:42.080 --> 00:19:48.420
Yeah. Yeah. Really cool. Also really cool is our new sponsor, Fusion Auth. Thank you

00:19:48.420 --> 00:19:53.400
them for sponsoring this episode. So let me just tell you really quickly about them. They're an

00:19:53.400 --> 00:19:59.220
authentication and authorization platform built for devs, by devs. It solves the problems of building

00:19:59.220 --> 00:20:05.960
essential user security without adding the risk and distraction from your main app. Fusion Auth has all

00:20:05.960 --> 00:20:11.640
the features you need to, for great support at a price that won't break bank. And you can either do

00:20:11.640 --> 00:20:17.280
self-hosting or you can get a fully managed solution running in any AWS region. So if you've got a side

00:20:17.280 --> 00:20:22.440
project that needs a custom login registration or multi-factor authentication, social logins, or user

00:20:22.440 --> 00:20:28.480
management, you can download Fusion Auth and get the community edition for free. And the best part is you can have

00:20:28.480 --> 00:20:33.340
unlimited users and there's no credit card or subscription required for that. So check them

00:20:33.340 --> 00:20:39.800
out at pythonbytes.fm/Fusion Auth or just click the link in your podcast player show notes and,

00:20:40.280 --> 00:20:43.760
let them know you came from us. I want that t-shirt. Thank you, Fusion Auth. That's cool. I know.

00:20:43.760 --> 00:21:10.260
Yeah. You got, get a cool t-shirt, cat slash et cetera slash password, D. Yeah. Very cool. Nice. I love when you get a cool t-shirt from our sponsors. All right. Well, Sue doesn't like cats. I know. And kitties. And kitties. And kitties. I can tell that you're already a fan of kitties. well, so, I don't know if, kitty is parallelized, but,

00:21:10.260 --> 00:21:40.240
Yeah. So I want to talk about parallels and parallelization say that three times. anyway, I found this article, by, Jamie Welta. Cool. Last name actually. but it's called futures and easy parallelization. And, I was like, you know, it was a pretty short article and I was like, it can't be that easy. but so this isn't talking about, AIO stuff, ACE or asyncio. It's, it's talking about

00:21:40.240 --> 00:22:09.720
this one is talking about thread futures with threads. And this is, it's a, it's pretty cool. The idea is you've got just maybe you've got, and it starts off with a simple example. I just have some work that I want done and I want it done on, on different threads or different processors. So, this, this example, brings up a thread pool, a thread pool executor, and then runs them all at the same time. does an executor submit?

00:22:10.220 --> 00:22:28.120
And it's just a small snippet of code. It's just a handful of lines. And then I tried this out. So this example actually, is kind of boring. It's just doing, like a power X to the power of two, or X squared. I'm on a couple of things. I think that's what star star is, isn't it? Is that power of, I don't remember.

00:22:28.120 --> 00:22:31.500
Yeah. X to the power of two X. Yeah. X squared.

00:22:31.500 --> 00:22:51.360
X squared. So, the other example seems a bit, a bit more, down to earth and that's, and yes, on our screen, on the, on the YouTube screen is just, it's the entire program here. it's just, you're taking a few, a few websites and a couple of pages to go to.

00:22:51.420 --> 00:23:04.420
And, and then actually just slurping those down with requests and grabbing something about them. And this example just, as the result, whether it's a 200 or something like that, but it's a really short example.

00:23:04.420 --> 00:23:29.200
And you've got parallelization going on. And I played with this, just downloaded it. The only, we'll have it in our show notes. The only error on this that I had to do is it's using, it's using time in here is just like a debug thing. And in the example, doesn't import time. So you have to add, add that import time. And it runs just fine like this. And this is a pretty quick way to add parallelization for some quick task.

00:23:29.420 --> 00:23:48.780
So I kind of like it. There's occasionally, especially like I would do it. there's a lot of huge log files I have to parse or, or big data files that I'm looking for stuff on or grabbing, grabbing error logs off of different systems. And this would be a great example to just grab, grab them all at the same time and pull them in. So.

00:23:48.780 --> 00:24:03.880
Yeah. Yeah. Yeah. That's nice. You know, one thing that's cool about the futures you get back from the thread pool executor is you can say dot result and it blocks. Whereas on asyncio, it throws an exception and says it's not done rather than just blocking.

00:24:03.880 --> 00:24:18.620
Oh yeah. Yeah. And that's the article kind of talks about that. It's one of the simplest things is you, you tell the executors, you call executor submit and that gets the jobs ready, but that doesn't block. Those are, you can, you can submit as many as you want.

00:24:18.780 --> 00:24:41.820
And then in the example, he's just using few like future dot result, in a, in, in a list comprehension and that for each of those result that'll block until the next one's done. And you know, this one's doing it in an order of which one you submitted it, that might not be the order they finish in, but you don't really care because you just want to wait till they're all done anyway. So.

00:24:42.040 --> 00:24:54.480
Yeah, exactly. If you block on the first one, it's not done. The second one might finish first, but it'll be done by the time you get to them. Yeah. Yeah. Yeah. And this is a lot more natural for folks who may not be used to like asyncio too.

00:24:54.480 --> 00:24:56.960
Oh, I've been deep in the asyncio world.

00:24:56.960 --> 00:24:59.320
Well, it's all built natural here.

00:24:59.320 --> 00:25:01.000
And that's, that's.

00:25:01.000 --> 00:25:03.320
And I have scars now, let me tell you.

00:25:03.320 --> 00:25:09.520
That's exactly why I wanted to bring up this article is because there's a lot of stuff where like a, like a, maybe a DevOps person or something.

00:25:10.020 --> 00:25:19.480
They're not, they're not writing async programs, but they might have a async need or asynchronous needs that can be solved with a simple, some simpler code.

00:25:19.480 --> 00:25:20.060
So.

00:25:20.060 --> 00:25:23.220
Yeah. This is very, very elegant, easy to understand.

00:25:23.220 --> 00:25:25.080
Yeah. Nice article.

00:25:25.080 --> 00:25:25.920
Good one. All right.

00:25:25.920 --> 00:25:29.240
Well, I want to talk about databases and more tools.

00:25:29.240 --> 00:25:31.380
I feel like this is just the tool focused.

00:25:31.380 --> 00:25:32.500
Like the tool episode.

00:25:32.500 --> 00:25:34.400
It is. It's full time.

00:25:34.400 --> 00:25:34.740
All right.

00:25:35.300 --> 00:25:45.200
So I did an episode on talk Python with Emily Morehouse, glyph and Hennick and Hennick pointed out this thing called PG mustard.

00:25:45.200 --> 00:25:46.460
Have you heard of this?

00:25:46.460 --> 00:25:47.020
No.

00:25:47.020 --> 00:25:47.720
Have you?

00:25:47.720 --> 00:25:51.720
Oh, well, I just listened to that excellent episode and heard about it.

00:25:51.720 --> 00:26:00.040
So now, you know, but other than that, like I had not heard of it, but one of the challenges, so many websites, I just don't understand why the world works this way.

00:26:00.040 --> 00:26:09.880
But you go to the website and it just spins and spins and the clunkier, the more internal the thing looks, the more likely it is to take 10 seconds to do whatever it's doing.

00:26:09.880 --> 00:26:14.280
Right. But, you know, it's doing some database query, probably without an index.

00:26:14.280 --> 00:26:20.420
Maybe they gave it an index, but the index is not being used because it's actually filtering first on some other random thing or whatever.

00:26:20.940 --> 00:26:27.420
So databases have this cool feature to say, given a query, explain how you're going to execute this.

00:26:27.420 --> 00:26:28.940
MongoDB has this.

00:26:28.940 --> 00:26:30.920
Postgres has this and so on.

00:26:30.920 --> 00:26:33.180
OK, so that's that comes out as text.

00:26:33.180 --> 00:26:35.680
What if you could have a better way that gave you advice?

00:26:35.680 --> 00:26:38.680
And that's what this tool here is, which does cost money.

00:26:38.680 --> 00:26:42.880
Just to be clear, it's a commercial thing, but I thought it was cool enough that I wanted to point it out to people.

00:26:43.560 --> 00:26:59.500
So what you do is you give it your basically a select statement and you ask it to explain it and it will it'll break down the explain statement into different sections and tell you this part is really good.

00:26:59.580 --> 00:27:03.440
This part of of the query could be improved and so on.

00:27:03.440 --> 00:27:10.660
And then it gives you so like it'll it'll show you this beautiful visual way of explaining it and you can dive into it.

00:27:10.660 --> 00:27:14.200
And if you click on it, it'll tell you things like, OK, this is a nested loop.

00:27:14.200 --> 00:27:17.740
And on this part of the query, it took one hundred and fifty two milliseconds.

00:27:17.740 --> 00:27:18.980
You got one hundred rows back.

00:27:18.980 --> 00:27:23.960
And then it actually describes the situation, why it's good or bad.

00:27:23.960 --> 00:27:29.500
So, for example, it says you got five stars because you discarded one point three million rows.

00:27:29.500 --> 00:27:30.800
That makes it faster.

00:27:30.800 --> 00:27:36.880
But you only got three point two stars because the row estimate was out by a factor of 42.

00:27:36.880 --> 00:27:38.860
You know, try to get that from text, right?

00:27:38.860 --> 00:27:45.340
This is this is super helpful if you've got a slow site that you want to say, OK, this page is slow.

00:27:45.340 --> 00:27:48.100
These are the three queries that run when we pull this page.

00:27:48.100 --> 00:27:49.260
Why are they slow?

00:27:49.260 --> 00:27:50.360
How can I make them better?

00:27:50.360 --> 00:27:55.820
So it's you know, we talked about the regex one on one thing, how it like kind of guided you through and gave you recommendations.

00:27:55.820 --> 00:27:57.240
This is like the database equivalent.

00:27:57.240 --> 00:27:58.280
This is nice.

00:27:58.280 --> 00:27:59.300
This is awesome.

00:27:59.300 --> 00:28:01.500
I can't believe I've never seen this before.

00:28:01.500 --> 00:28:02.740
Well, I know I have.

00:28:02.740 --> 00:28:03.580
I can't either.

00:28:03.580 --> 00:28:04.620
I've never seen it either.

00:28:04.620 --> 00:28:11.200
Now, from the from the interview, it sounded like it would recommend how you could change your query to make it better.

00:28:11.200 --> 00:28:14.200
Is that something it has in there or did I imagine that?

00:28:14.200 --> 00:28:15.160
I believe so.

00:28:15.160 --> 00:28:15.860
And I believe so.

00:28:15.860 --> 00:28:23.040
If you like open up this 3.2 stars, I think it'll give you descriptions about what could be better in there.

00:28:23.040 --> 00:28:30.620
So it can give you performance advice, including high index potentials or index efficiency, disk operations.

00:28:30.620 --> 00:28:33.100
So like you've got to read too much off this to answer this question.

00:28:33.100 --> 00:28:42.280
Poor cash performance, excessive heat fetches, read efficiencies, glossy bitmap scans and on and on and on.

00:28:42.280 --> 00:28:42.680
Right.

00:28:42.680 --> 00:28:44.540
So it's pretty cool.

00:28:44.540 --> 00:28:47.720
It runs on Postgres 9.6 or newer.

00:28:47.720 --> 00:28:49.700
I hope you're newer than that 9.6.

00:28:49.700 --> 00:28:51.440
That's that's pretty great.

00:28:51.440 --> 00:28:52.500
It supports that far back.

00:28:52.500 --> 00:28:53.420
Yeah.

00:28:53.420 --> 00:28:53.820
Yeah.

00:28:53.820 --> 00:28:56.020
Anyway, it is a paid tool.

00:28:56.020 --> 00:29:04.160
But if you could for ninety five dollars, make your website ten times faster and people have been complaining and complaining, you don't have to rewrite anything.

00:29:04.160 --> 00:29:10.480
You just put in like a slightly different hint or index or change the order of a query like that.

00:29:10.480 --> 00:29:11.460
That's that's worth a lot.

00:29:11.560 --> 00:29:23.200
I think I'm just going to try to learn this and then set up a page to say I'm a database optimization consultant and just run this in the background and say, yeah, look, five hundred dollars an hour.

00:29:23.200 --> 00:29:24.940
I will absolutely come in there.

00:29:24.940 --> 00:29:25.280
Yeah.

00:29:25.280 --> 00:29:30.980
And I have this new business proprietary set of tools that I've I just I can't talk about it.

00:29:30.980 --> 00:29:33.620
But you let me in there and magic's going to happen.

00:29:33.620 --> 00:29:35.420
I shouldn't have said that out loud.

00:29:36.040 --> 00:29:36.400
Yeah.

00:29:36.400 --> 00:29:36.440
Yeah.

00:29:36.440 --> 00:29:40.160
Well, I guess that the market will be swamped with these folks.

00:29:40.160 --> 00:29:40.660
Yeah.

00:29:40.660 --> 00:29:42.800
Anyway, I thought this was cool.

00:29:42.800 --> 00:29:43.980
So I wanted to give it a shout out.

00:29:43.980 --> 00:29:44.660
Cool.

00:29:44.660 --> 00:29:45.300
Nice.

00:29:45.300 --> 00:29:45.860
That is super cool.

00:29:45.860 --> 00:29:46.460
Yeah.

00:29:46.460 --> 00:29:47.420
All right.

00:29:47.780 --> 00:29:48.620
Calvin, you got the last one.

00:29:48.620 --> 00:29:49.180
All right.

00:29:49.180 --> 00:29:49.820
Last one up.

00:29:49.820 --> 00:29:51.580
Continuing the tools parade.

00:29:51.580 --> 00:29:52.900
Another tool.

00:29:52.900 --> 00:29:54.600
This is also cross platform.

00:29:54.600 --> 00:29:55.660
I didn't mention that before.

00:29:55.660 --> 00:29:58.460
One of the reasons I really like Kitty was the fact I can use it anywhere.

00:29:58.460 --> 00:30:01.360
Linux, BSD, Windows, Mac.

00:30:01.360 --> 00:30:03.800
There are downloads for all those platforms.

00:30:04.480 --> 00:30:08.500
This one doesn't support Windows, but it does support Linux, Mac and FreeBSD.

00:30:08.500 --> 00:30:10.340
It's BPYTOP.

00:30:10.340 --> 00:30:13.420
I used to be a longtime user of Glances.

00:30:13.420 --> 00:30:16.080
And if you didn't know what Glances was, you were also missing out.

00:30:16.080 --> 00:30:19.720
Because Glances is an awesome way to see what's going on in your system.

00:30:19.720 --> 00:30:23.220
Like what I was being used, how much memory is being used, how much swath is being used.

00:30:23.220 --> 00:30:26.420
And BPYTOP is kind of the next generation of that.

00:30:26.420 --> 00:30:29.560
So I will show a quick little demo of this one as well.

00:30:29.560 --> 00:30:34.060
So for those of you who weren't familiar with Glances, this is what Glances looks like.

00:30:34.060 --> 00:30:39.040
Sorry, a little interruption there.

00:30:39.040 --> 00:30:42.080
But while I'm live here on the podcast, this is Glances.

00:30:42.080 --> 00:30:46.280
It's kind of like more tech, very tech-y, kind of old school looking.

00:30:46.280 --> 00:30:50.900
But if you just PipX install, and that's how I typically install these kinds of tools.

00:30:50.900 --> 00:30:53.280
Sorry about that.

00:30:53.280 --> 00:30:54.340
It's all good.

00:30:54.340 --> 00:30:58.720
PipX is the homebrew.

00:30:58.720 --> 00:30:59.340
Oh, man.

00:30:59.340 --> 00:30:59.780
It's amazing.

00:30:59.780 --> 00:31:00.840
Python things, right?

00:31:00.840 --> 00:31:03.340
You just PipX install BPYTOP.

00:31:03.340 --> 00:31:11.480
If you don't have PipX installed, you should install PipX because that'll get you access to all the stuff and your path all set up.

00:31:11.480 --> 00:31:13.340
But now I just use BPYTOP.

00:31:13.340 --> 00:31:19.680
And you get this nice colorized view of a dashboard.

00:31:19.680 --> 00:31:22.180
It's all really just laid out well.

00:31:22.740 --> 00:31:28.940
And then all the, you can kind of see on here, there's like characters that are shaded in a different color.

00:31:28.940 --> 00:31:33.000
If you, you know, hit those characters, you'll be able to like resort.

00:31:33.340 --> 00:31:40.860
Or if you see the little numbers, I can hide and show the CPU or the memory graph if I don't care about that one so much.

00:31:40.860 --> 00:31:47.700
So for people who are just listening, here's a terminal app that has like task manager.

00:31:47.700 --> 00:31:48.640
Oh, yeah.

00:31:48.760 --> 00:31:53.980
Or activity monitor levels of sort of graphs going on of like, here's the CPU over time.

00:31:53.980 --> 00:31:56.400
Here's the running processes sort of by CPU.

00:31:56.400 --> 00:31:58.100
Here's the network.

00:31:58.100 --> 00:32:01.340
This is probably more useful than activity monitor, honestly.

00:32:01.340 --> 00:32:02.140
Oh, I think it is.

00:32:02.140 --> 00:32:05.620
I mean, what's nice is you get that trending metrics over time.

00:32:05.620 --> 00:32:13.440
So you can see by CPU core or by like kind of aggregated CPU view, how, you know, if you're seeing spikes or what.

00:32:13.440 --> 00:32:18.680
And this is really useful if you're on a server and like something's periodically happening, you're not sure what.

00:32:18.680 --> 00:32:22.580
And you can kind of track down like either IO issues or CPU spikes.

00:32:22.580 --> 00:32:25.840
And you can kind of see if they're becoming very like periodic.

00:32:25.840 --> 00:32:29.360
Maybe they're happening every minute or every like five minutes, like on the dot.

00:32:29.360 --> 00:32:30.180
And you're like, oh, that's weird.

00:32:30.180 --> 00:32:32.040
There's something like maybe it's this cron job.

00:32:32.040 --> 00:32:34.180
So it helps you track that, track those kinds of things down.

00:32:34.280 --> 00:32:43.900
You can also inspect the processes so you can arrow up and down and you can actually like hit return and see like what CPU specifically or memory like a specific process is.

00:32:43.900 --> 00:32:47.860
You can like dig down into a specific process and see what core it's actually running on.

00:32:47.860 --> 00:32:51.240
It's just, again, for tracking down performance issues.

00:32:51.240 --> 00:32:53.880
I'm just using it locally on my own laptop right here.

00:32:53.880 --> 00:32:59.000
But I've used this numerous to every machine I log into for, you know, customers or production type stuff.

00:32:59.000 --> 00:33:00.980
They're still using virtual machines.

00:33:01.400 --> 00:33:05.420
This is absolutely installed so that when they're like, oh, something's slow or something's doing weird.

00:33:05.420 --> 00:33:11.020
Like I just go fire these up and take a look real quick to get kind of a snapshot in real time what's going on.

00:33:11.020 --> 00:33:12.520
I've done that with glances.

00:33:12.520 --> 00:33:13.280
Yeah.

00:33:13.280 --> 00:33:14.500
That was used to my go to.

00:33:14.500 --> 00:33:18.140
But I just found B5 Top was like the super powered version of glances.

00:33:18.140 --> 00:33:19.200
Interesting.

00:33:19.200 --> 00:33:19.920
You've moved over.

00:33:19.920 --> 00:33:21.280
Yeah, the graphs are way better.

00:33:21.280 --> 00:33:21.920
Yeah.

00:33:22.280 --> 00:33:28.540
Like you have progress bars or like meter bars that are graphical in glances if you make it wide enough.

00:33:28.540 --> 00:33:29.880
But they don't have over time.

00:33:29.880 --> 00:33:30.900
They're just like snapshots.

00:33:30.900 --> 00:33:32.900
And these are like beautiful gradient colors.

00:33:32.900 --> 00:33:38.020
Like I kind of just expanded the net one so you can see the traffic going across my card.

00:33:38.020 --> 00:33:41.800
You can also switch back and forth between different interfaces on the system.

00:33:41.800 --> 00:33:46.940
So if you've got multiple network interfaces, you can see the aggregate or just for a specific interface.

00:33:47.480 --> 00:33:52.000
Yeah, super helpful when trying to track down, you know, weird, you know, in quotes, weird issues.

00:33:52.000 --> 00:33:53.980
How's it run on Kitty?

00:33:53.980 --> 00:33:55.780
It runs great on Kitty.

00:33:55.780 --> 00:33:57.000
The performance is amazing.

00:33:57.000 --> 00:34:01.320
That's another thing I didn't show you is like you can actually see with the NVIDIA SMI tool.

00:34:01.320 --> 00:34:06.460
Like there is Kitty using up 20 megabytes of my GPU memory on there.

00:34:06.460 --> 00:34:07.120
Oh my goodness.

00:34:07.120 --> 00:34:09.000
No, that's pretty awesome.

00:34:09.000 --> 00:34:13.580
Speaking of beautiful, Alvaro says B5 Top has themes.

00:34:13.580 --> 00:34:14.000
Yes.

00:34:14.000 --> 00:34:16.060
They use the Darkula theme.

00:34:16.500 --> 00:34:23.660
Yeah, I love the fact that anything's got themes I can customize like, you know, Kitty or even B5 Top or whatever my IDE is.

00:34:23.660 --> 00:34:25.780
I just, I trick that stuff out.

00:34:25.780 --> 00:34:26.680
This is my environment.

00:34:26.680 --> 00:34:29.160
I want to be as comfortable and as productive as possible.

00:34:29.160 --> 00:34:31.600
So the more customizable, the better.

00:34:31.600 --> 00:34:32.660
And the more emojis, the better.

00:34:32.660 --> 00:34:33.380
Love emojis.

00:34:33.380 --> 00:34:34.120
Yes.

00:34:34.120 --> 00:34:37.500
There's something to be said about it.

00:34:37.500 --> 00:34:39.300
If you sit down and you're like, I am excited.

00:34:39.300 --> 00:34:40.300
Look how cool this is.

00:34:40.300 --> 00:34:41.360
I'm excited to play with this.

00:34:41.360 --> 00:34:41.720
Yeah.

00:34:41.720 --> 00:34:44.980
You're like, oh, I'm using like an old version of Bash with nothing else installed.

00:34:44.980 --> 00:34:46.980
This is not as much fun as I envisioned it to be.

00:34:46.980 --> 00:34:52.860
Well, the only issue is when you sit down with someone who's like, they fire up text edit to like edit some text.

00:34:52.860 --> 00:34:53.760
You're like, what are you doing?

00:34:53.760 --> 00:34:55.200
Like, come on.

00:34:55.200 --> 00:34:56.680
Like, let me show you some cool tools.

00:34:56.680 --> 00:34:58.220
Like, let me get you up to speed on here.

00:34:58.220 --> 00:34:59.160
Yeah.

00:34:59.160 --> 00:34:59.420
Yeah.

00:34:59.420 --> 00:35:02.680
Text edit being the notepad equivalent if you're not a Mac person.

00:35:02.680 --> 00:35:02.920
Yeah.

00:35:03.020 --> 00:35:05.020
That's maybe it's a word pad.

00:35:05.020 --> 00:35:06.740
You know, maybe it's a word pad level.

00:35:06.740 --> 00:35:08.780
Like, that's probably where it, which is worse.

00:35:08.780 --> 00:35:10.260
I think that's worse than notepad.

00:35:10.260 --> 00:35:10.600
It is.

00:35:10.600 --> 00:35:13.000
Because you're going to get weird, corrupted characters that you're not going to know.

00:35:13.000 --> 00:35:13.680
Yeah.

00:35:13.680 --> 00:35:14.660
Oh, man.

00:35:14.660 --> 00:35:24.300
One of the, especially with, with working from home now, a lot of people are, are working with kids around that walk by and you want your job to look awesome.

00:35:24.300 --> 00:35:26.420
So that they're interested in what you're doing.

00:35:26.420 --> 00:35:27.160
Just saying.

00:35:27.160 --> 00:35:28.040
Yeah.

00:35:28.040 --> 00:35:29.340
I'm sure my kids think I'm a hacker.

00:35:29.340 --> 00:35:34.400
You're not, wait, you're not a hacker.

00:35:34.400 --> 00:35:36.060
Well, I hack on code.

00:35:36.060 --> 00:35:36.460
Yes.

00:35:36.460 --> 00:35:40.360
The, the original, the original.

00:35:40.360 --> 00:35:40.840
Exactly.

00:35:40.840 --> 00:35:42.160
The original meaning of that word.

00:35:42.160 --> 00:35:42.760
Yeah.

00:35:42.760 --> 00:35:46.380
Brian, time for some extras.

00:35:46.380 --> 00:35:49.680
I do have a big extra that I'm really excited about.

00:35:49.680 --> 00:35:50.220
Yes.

00:35:50.220 --> 00:35:53.760
The book is, which I've been talking about for about 18 months.

00:35:54.120 --> 00:35:58.940
And if you add that to the previous 18 months, about three years of this podcast has been talking about this book.

00:35:58.940 --> 00:36:04.240
But anyway, so it's, there's no longer a beta flag on it.

00:36:04.240 --> 00:36:05.800
It's not in beta anymore.

00:36:05.800 --> 00:36:07.420
So it's, it's off to the printers.

00:36:07.420 --> 00:36:12.400
And, and then to celebrate it being officially released.

00:36:12.400 --> 00:36:19.140
It is, there's a coupon code that we'll link to this page in the show notes, but it's a coupon code.

00:36:19.140 --> 00:36:24.060
I don't know how long this is going to be good for, but this is for 40% off the ebook.

00:36:24.060 --> 00:36:25.880
So this is exciting.

00:36:25.880 --> 00:36:28.320
And I don't have a physical copy yet.

00:36:28.320 --> 00:36:30.220
I'm still waiting for mine to get delivered.

00:36:30.220 --> 00:36:32.640
Hopefully it'll be in the next couple of weeks.

00:36:32.640 --> 00:36:34.240
So, yeah.

00:36:34.240 --> 00:36:36.380
Anyway, that's, that's one of my extras.

00:36:36.380 --> 00:36:39.580
The other extra I wanted to bring up is a pie camp.

00:36:39.960 --> 00:36:41.460
Spain is happening.

00:36:41.460 --> 00:36:44.220
April 15th through the 18th.

00:36:44.220 --> 00:36:46.300
And man, this looks fun.

00:36:46.300 --> 00:36:48.960
It's like actual camping.

00:36:48.960 --> 00:36:50.220
I love the idea.

00:36:50.220 --> 00:37:01.820
Well, like, I don't know if it's actual camping, but there's a, admission includes, four days and three nights, including accommodations and breakfast, lunch and dinner provided.

00:37:01.960 --> 00:37:03.320
This is a pretty amazing.

00:37:03.780 --> 00:37:06.040
I know, Brian, I see karaoke on that list too.

00:37:06.040 --> 00:37:07.840
Karaoke talks.

00:37:07.840 --> 00:37:08.520
Yeah.

00:37:08.520 --> 00:37:09.620
Games, ping pong.

00:37:09.620 --> 00:37:11.280
Ah, this looks great.

00:37:11.280 --> 00:37:14.000
You have to give your talk in song form.

00:37:14.000 --> 00:37:14.420
Yeah.

00:37:14.420 --> 00:37:14.980
Oh man.

00:37:14.980 --> 00:37:16.860
No one, no one would want to see me do that.

00:37:16.860 --> 00:37:17.440
No one.

00:37:17.560 --> 00:37:18.360
Or me either.

00:37:18.360 --> 00:37:19.920
So this looks great.

00:37:19.920 --> 00:37:21.800
It does look like a lot of fun.

00:37:21.800 --> 00:37:24.280
Fantastic.

00:37:24.280 --> 00:37:26.060
Calvin, you got anything extra you want to throw out there?

00:37:26.060 --> 00:37:26.780
I do.

00:37:26.780 --> 00:37:31.620
coming up next month and just a little over a month is the Python web conference.

00:37:31.620 --> 00:37:33.800
Oh, I've got the, let me pull up the slide for it.

00:37:33.800 --> 00:37:34.740
You've got the screen.

00:37:34.740 --> 00:37:36.780
I do have the screen for it.

00:37:36.780 --> 00:37:39.960
I had even, even pre-planned for this to be ready to roll.

00:37:39.960 --> 00:37:41.740
So it is Python web conference time.

00:37:41.740 --> 00:37:42.840
this is our fourth.

00:37:42.840 --> 00:37:43.820
Got any good speakers or what?

00:37:43.820 --> 00:37:44.900
Fourth annual event.

00:37:44.900 --> 00:37:47.260
we've got some amazing speakers.

00:37:47.260 --> 00:37:49.420
who are going to join us this year.

00:37:49.420 --> 00:37:52.980
So I'll actually bring that up because I'm really proud of this group.

00:37:52.980 --> 00:37:59.120
if you scroll down through here, there is just a amazing, bunch of people who have

00:37:59.120 --> 00:38:03.040
signed on for this amazing adventure with all of us, over here.

00:38:03.040 --> 00:38:04.580
So definitely check it out.

00:38:04.580 --> 00:38:07.000
It's going to be way bigger than it has been in previous years.

00:38:07.000 --> 00:38:08.900
So this is the fourth year we've run it.

00:38:08.900 --> 00:38:11.740
And I believe we've got 90 speakers this year.

00:38:11.740 --> 00:38:16.460
We are doing, five tracks across five days.

00:38:16.600 --> 00:38:21.720
So there's two app dev tracks, a culture track, a cloud track, and a pie data track.

00:38:21.720 --> 00:38:23.400
so there is something for everybody.

00:38:23.400 --> 00:38:25.060
get your tickets.

00:38:25.060 --> 00:38:27.180
Now it is going to be a ton of fun.

00:38:27.180 --> 00:38:30.220
We will start, you know, getting things cranked up a couple of days beforehand.

00:38:30.220 --> 00:38:34.240
We've getting, you know, the Slack channels all set up and people can start basically hanging

00:38:34.240 --> 00:38:34.520
out.

00:38:34.520 --> 00:38:36.000
And we're going to have some cool socials.

00:38:36.000 --> 00:38:40.620
I know we've got one of our speakers is going to give a mindfulness, social.

00:38:40.620 --> 00:38:45.020
So if you want to come and learn how to decompress as a developer, and she's going to actually

00:38:45.020 --> 00:38:46.540
be one of our keynotes about burnout.

00:38:46.540 --> 00:38:51.800
but she's going to, you know, give a practical example during one of the socials that I'm super

00:38:51.800 --> 00:38:52.480
excited to try out.

00:38:52.480 --> 00:38:53.120
Nice.

00:38:53.120 --> 00:38:53.560
Fantastic.

00:38:53.560 --> 00:38:54.280
Yeah.

00:38:54.280 --> 00:38:57.620
I see a bunch of the people in the speaker list have been here on the show.

00:38:57.860 --> 00:38:58.040
Yeah.

00:38:58.040 --> 00:39:01.160
These should, these should, these should not be strangers to, especially this guy

00:39:01.160 --> 00:39:01.620
right here.

00:39:01.620 --> 00:39:02.540
He's definitely not a stranger.

00:39:02.540 --> 00:39:03.060
I don't know about that guy.

00:39:03.060 --> 00:39:03.480
He's shady.

00:39:03.480 --> 00:39:04.520
Definitely shady.

00:39:04.520 --> 00:39:10.160
Well, I was, I'm noticing a lot of these speakers from either this, show or talk Python

00:39:10.160 --> 00:39:11.820
or, testing code.

00:39:11.820 --> 00:39:15.560
They've been, a lot of people have been one of those friendly faces, a lot of friendly

00:39:15.560 --> 00:39:16.280
faces on here.

00:39:16.280 --> 00:39:18.840
And again, great, great group of people.

00:39:18.840 --> 00:39:20.880
They're all super excited to participate in the conference.

00:39:20.880 --> 00:39:24.600
They're all super excited to like hang out with everybody and like, just be a part.

00:39:24.600 --> 00:39:25.200
Yeah.

00:39:25.260 --> 00:39:29.800
I like that you're putting, the social links up on the page so that people can check

00:39:29.800 --> 00:39:31.940
that out instead of having to Google for them or something.

00:39:31.940 --> 00:39:32.300
Yeah.

00:39:32.300 --> 00:39:33.940
It's all about the people for me.

00:39:33.940 --> 00:39:38.200
I mean, I'm, I'm, I love being a community builder and, and putting this together for folks.

00:39:38.200 --> 00:39:41.520
Oh, look, there's another amazing speakers in the, in the audience right now.

00:39:41.520 --> 00:39:44.120
Fantastic.

00:39:44.120 --> 00:39:44.880
Yeah.

00:39:44.880 --> 00:39:45.560
That is awesome.

00:39:45.560 --> 00:39:50.060
Well, how about, no, I don't mean to cut you off, but I was just curious if Michael had

00:39:50.060 --> 00:39:50.680
any extras.

00:39:50.680 --> 00:39:52.160
You, you know that I do.

00:39:52.160 --> 00:39:54.040
All right.

00:39:54.040 --> 00:39:54.560
I got a couple.

00:39:54.560 --> 00:39:59.240
Let me, let me tell you about this little app I got, which I meant to do a little video

00:39:59.240 --> 00:40:00.080
so I could show you.

00:40:00.080 --> 00:40:04.640
I'm a huge fan of macOS and, I really enjoy working there.

00:40:04.640 --> 00:40:10.920
I love the, like the terminal tools are like server stuff, but it's not, you know, you got

00:40:10.920 --> 00:40:12.140
all the nice little tools and whatnot.

00:40:12.140 --> 00:40:19.720
One of the things that I absolutely just don't understand is switching between windows is like

00:40:19.720 --> 00:40:21.680
nearly impossible if it's the same app.

00:40:21.800 --> 00:40:26.740
If I got one web browser set of tabs and another, I'm going to cycle between them like command

00:40:26.740 --> 00:40:29.880
tab, the alt tab equivalent has no effect on that.

00:40:29.880 --> 00:40:30.220
Right?

00:40:30.220 --> 00:40:30.940
Like why is this?

00:40:30.940 --> 00:40:34.440
So I found this cool app called witch that lets you do all sorts of stuff.

00:40:34.440 --> 00:40:40.280
like, you map it like alt tab instead of command tab and it'll pull up.

00:40:40.280 --> 00:40:44.360
It's very similar, but then it'll, you can even like switch between tabs within a browser.

00:40:44.360 --> 00:40:49.280
So I want to switch to Vivaldi, but onto this tab of that Vivaldi.

00:40:49.380 --> 00:40:52.780
So how, wherever it lives on what Vivaldi window, I don't care.

00:40:52.780 --> 00:40:54.540
I just want to go to that tab, stuff like that.

00:40:54.540 --> 00:40:56.000
Super, super cool.

00:40:56.000 --> 00:41:00.040
It's just cycle between the last use window instead of the last use app.

00:41:00.040 --> 00:41:03.640
And there's just a, the customizability of it is insane.

00:41:03.640 --> 00:41:06.100
Like it's, it's truly a crazy.

00:41:06.100 --> 00:41:07.200
And what does it cost?

00:41:07.200 --> 00:41:08.520
It costs $14 once.

00:41:08.620 --> 00:41:11.340
So if that frustrated you, check that out.

00:41:11.340 --> 00:41:15.740
Number two is I did this video called don't use loops.

00:41:15.740 --> 00:41:17.940
Or do you actually need loops in Python?

00:41:17.940 --> 00:41:22.080
It was really to say like some of the time you can use comprehensions of various types.

00:41:22.080 --> 00:41:23.440
That already talked about.

00:41:23.440 --> 00:41:28.080
But in response to that, someone said, oh, I don't really think there's any difference

00:41:28.080 --> 00:41:31.100
between using a list comprehension and a for loop.

00:41:31.100 --> 00:41:32.220
They're the same.

00:41:32.220 --> 00:41:34.400
Like, how could you even tell me that they're different?

00:41:34.400 --> 00:41:38.580
Well, one import dis from, from dis import dis, dis like,

00:41:38.580 --> 00:41:40.240
disassemble and you'll see a big difference.

00:41:40.240 --> 00:41:43.740
But two, I put together an example that for 10 million times,

00:41:43.740 --> 00:41:46.340
basically adds the numbers one to 10 million,

00:41:46.340 --> 00:41:51.400
even numbers one to 10 million to a list using a for loop

00:41:51.400 --> 00:41:52.440
and then using a list comprehension.

00:41:52.440 --> 00:41:58.200
And it is about 25% faster to do the list comprehension than the loop,

00:41:58.200 --> 00:42:00.780
which isn't going to change people's world probably,

00:42:00.780 --> 00:42:02.260
but it's, you know, something to consider.

00:42:02.260 --> 00:42:02.960
Yeah.

00:42:02.960 --> 00:42:05.920
So I'll link into a very small gist there.

00:42:05.920 --> 00:42:07.400
I just.

00:42:07.400 --> 00:42:10.540
My, that peeve of mine.

00:42:10.540 --> 00:42:13.360
If you're going to do a loop, at the very least,

00:42:13.360 --> 00:42:16.600
don't do for I in length of something.

00:42:16.600 --> 00:42:18.420
That's C.

00:42:18.420 --> 00:42:19.380
That's not Python.

00:42:19.380 --> 00:42:21.140
Yes, please.

00:42:21.140 --> 00:42:23.560
Or, or create a number.

00:42:23.560 --> 00:42:26.100
Count equal, you know, I equals zero.

00:42:26.100 --> 00:42:29.140
While I lessen this, I plus plus on the inside, right?

00:42:29.140 --> 00:42:31.240
Like, yeah, there's a lot of bad variations.

00:42:32.060 --> 00:42:32.460
Yeah.

00:42:32.460 --> 00:42:37.140
Those are, those are, I intentionally put things like that in interview questions

00:42:37.140 --> 00:42:40.400
to try to see if people are really Python programmers or if they're.

00:42:40.400 --> 00:42:41.860
Yeah, exactly.

00:42:41.860 --> 00:42:45.260
And it might be fine that you're a C programmer coming into Python,

00:42:45.260 --> 00:42:48.880
but sometimes people will be dishonest with you during the interviews.

00:42:48.880 --> 00:42:50.880
Like, oh yes, I use Flask all the time.

00:42:50.960 --> 00:42:54.360
All right, how about you create a hello world view and run that?

00:42:54.360 --> 00:42:56.800
I can't, I can't do that.

00:42:56.800 --> 00:42:57.460
Okay, well.

00:42:57.460 --> 00:42:59.620
Then you probably don't use Flask all the time.

00:42:59.620 --> 00:43:00.680
You might use it sometimes.

00:43:00.680 --> 00:43:03.600
They're not, not eight hours a day like you told me.

00:43:03.600 --> 00:43:04.260
All right.

00:43:04.580 --> 00:43:12.760
Another thing, another similar little gist thing is I was working on using a database API

00:43:12.760 --> 00:43:18.100
that is async only, but I want to use it in the web app that is not async at all.

00:43:18.100 --> 00:43:19.220
How do you do that?

00:43:19.220 --> 00:43:19.780
All right.

00:43:19.780 --> 00:43:22.440
We talked about like the result and blocking and all how painful that is.

00:43:22.440 --> 00:43:26.980
So I came up with this little gist that was working great in production, in dev.

00:43:27.420 --> 00:43:33.200
So this really simple thing, you can just wrap up an async call and say, run it.

00:43:33.200 --> 00:43:36.360
It internally manages a little loop and it calls run async.

00:43:36.360 --> 00:43:40.160
So you've got like a database async call.

00:43:40.160 --> 00:43:46.440
You can just say, you know, go to the call and just say, run whatever, get the thing async

00:43:46.440 --> 00:43:47.460
with the parameters, right?

00:43:47.460 --> 00:43:48.600
So it's not like a decorator.

00:43:48.600 --> 00:43:50.420
You just call it really simple.

00:43:50.420 --> 00:43:56.220
Well, in practice, what I found trying to deploy this to a website was the database

00:43:56.220 --> 00:43:59.940
back end was doing weird stuff with like what thread it's running on.

00:43:59.940 --> 00:44:05.780
The web server, MicroWhisgi was like shuffling around like the order of when stuff ran on different

00:44:05.780 --> 00:44:07.660
threads and it was freaking out the event loop.

00:44:07.660 --> 00:44:13.340
And you get all these errors about like, this thing has become detached from its asyncio loop

00:44:13.340 --> 00:44:16.220
or it came from one loop and it's trying to continue on another loop.

00:44:16.220 --> 00:44:17.740
Just like, oh no, what is all this?

00:44:18.140 --> 00:44:23.760
So I ended up coming up with a massively crazier version that people can check out that basically

00:44:23.760 --> 00:44:28.120
coordinates all the work to a background thread, runs it all in the same place and puts it back.

00:44:28.120 --> 00:44:30.520
It works fabulously.

00:44:30.520 --> 00:44:31.600
It is horrifying.

00:44:31.600 --> 00:44:33.620
So you can take it for what it is.

00:44:33.620 --> 00:44:40.000
Anyway, as part of this conversation, maybe it works really well, but it looks really bad.

00:44:41.320 --> 00:44:42.100
Bill Jones.

00:44:42.100 --> 00:44:49.560
So from court, I believe sent over a thing that said, one of the problems with asyncio is if it's

00:44:49.560 --> 00:44:54.660
already running and then you call async version, which internally happens to use the same pattern,

00:44:54.660 --> 00:44:58.020
it's going to crash and say it's already running weird.

00:44:58.560 --> 00:45:04.180
So there's this thing called nest IO, which allows you to basically have a reentrancy.

00:45:04.180 --> 00:45:07.840
So if you get the runtime error, this event loop is already running.

00:45:07.840 --> 00:45:09.900
Well, if it is just run, you know, whatever.

00:45:09.900 --> 00:45:11.680
But that's the error you get.

00:45:11.680 --> 00:45:16.400
So this will allow you to basically re like continue on in the same loop.

00:45:16.400 --> 00:45:16.940
All right.

00:45:16.940 --> 00:45:17.800
Those are all my extras.

00:45:17.800 --> 00:45:19.080
I thought those were all a little fun.

00:45:20.080 --> 00:45:20.300
Nice.

00:45:20.300 --> 00:45:26.340
I can't believe combining threading and asyncio in the same little submodule is brave.

00:45:26.340 --> 00:45:29.620
I did not get to that position willingly.

00:45:29.620 --> 00:45:33.340
Not at all.

00:45:33.340 --> 00:45:36.020
Like, but everything I had tried, it didn't matter.

00:45:36.020 --> 00:45:39.280
And people say, oh, you should use asyncio dot run that manages it for you.

00:45:39.280 --> 00:45:40.660
Yeah.

00:45:40.660 --> 00:45:41.180
Except for that.

00:45:41.180 --> 00:45:45.180
It wasn't working in the weird web servers that are doing all sorts of threading tricks and

00:45:45.180 --> 00:45:46.100
just right.

00:45:46.100 --> 00:45:48.340
Like it was the only thing that worked.

00:45:48.340 --> 00:45:49.760
And so there it was.

00:45:49.760 --> 00:45:50.360
All right.

00:45:50.360 --> 00:45:53.600
That was not funny, but maybe I've got something funny for you.

00:45:53.600 --> 00:45:55.180
You ready for a joke?

00:45:55.180 --> 00:45:55.960
Yes.

00:45:55.960 --> 00:45:56.560
Always.

00:45:56.560 --> 00:45:57.320
Okay.

00:45:57.320 --> 00:46:07.040
So this one is about mistakes that people make with testing for truthiness versus assignment.

00:46:07.040 --> 00:46:12.480
And so it's a cartoon and there's these humans being ripped apart by robots.

00:46:12.480 --> 00:46:14.720
It says, oh no, the robots are killing us.

00:46:14.720 --> 00:46:18.740
And someone asks why, but why we never programmed to do this.

00:46:18.740 --> 00:46:23.160
And then there's like a computer with some code on the screen in the background.

00:46:23.160 --> 00:46:24.620
You see robots killing people.

00:46:24.620 --> 00:46:27.480
And it says, it has actually the code for the robot.

00:46:27.480 --> 00:46:30.980
It says, void, interact with humans.

00:46:30.980 --> 00:46:34.600
If is crazy robot equals true, kill humans.

00:46:34.600 --> 00:46:36.040
Else be nice to humans.

00:46:36.840 --> 00:46:39.020
But it's an assignment, not an equality.

00:46:39.020 --> 00:46:41.220
It's a single equals instead of a double equals.

00:46:41.220 --> 00:46:45.320
End of the world has come because of that.

00:46:45.320 --> 00:46:46.900
You've just assigned it to be a crazy killer robot.

00:46:46.900 --> 00:46:48.260
Crazy murdering robot.

00:46:48.260 --> 00:46:49.740
Yes, exactly.

00:46:49.740 --> 00:46:50.140
Yeah.

00:46:50.140 --> 00:46:50.700
Nice.

00:46:50.700 --> 00:46:58.760
Anthony would save us from this cartoon apocalypse by saying this, you know, remember your unit test.

00:46:58.760 --> 00:46:59.060
Yeah.

00:46:59.180 --> 00:47:00.140
And beta testers.

00:47:00.140 --> 00:47:04.560
Why do we keep losing QA people?

00:47:04.560 --> 00:47:05.680
I just don't understand.

00:47:05.680 --> 00:47:07.640
Where do they go?

00:47:07.640 --> 00:47:08.500
I don't know.

00:47:08.500 --> 00:47:10.740
Just ship it to beta.

00:47:10.740 --> 00:47:10.960
Yeah.

00:47:10.960 --> 00:47:12.160
Yeah, exactly.

00:47:12.160 --> 00:47:13.200
Exactly.

00:47:13.200 --> 00:47:13.900
What could go wrong?

00:47:13.900 --> 00:47:14.780
Segment your population.

00:47:14.780 --> 00:47:15.900
A-B test this stuff.

00:47:15.900 --> 00:47:18.760
Anyway.

00:47:18.760 --> 00:47:19.240
No, thanks.

00:47:19.240 --> 00:47:19.560
Nice.

00:47:20.220 --> 00:47:23.000
But thank you, Calvin, for coming on the show this time.

00:47:23.000 --> 00:47:23.840
It was totally fun.

00:47:23.840 --> 00:47:24.340
Love it.

00:47:24.340 --> 00:47:25.340
Yeah, absolutely.

00:47:25.340 --> 00:47:25.800
Brian.

00:47:25.800 --> 00:47:26.560
Thank you.

00:47:26.560 --> 00:47:26.800
Good to be here.

00:47:26.800 --> 00:47:27.440
That was a good time.

00:47:27.440 --> 00:47:27.680
Yeah.

00:47:27.680 --> 00:47:28.420
Always.

00:47:28.420 --> 00:47:29.160
See you later.

00:47:29.160 --> 00:47:29.640
Yep.

00:47:29.640 --> 00:47:29.920
Bye.

00:47:29.920 --> 00:47:30.380
Bye, everyone.

00:47:30.380 --> 00:47:32.440
Thanks for listening to Python Bytes.

00:47:32.440 --> 00:47:35.260
Follow the show on Twitter via at Python Bytes.

00:47:35.260 --> 00:47:38.460
That's Python Bytes as in B-Y-T-E-S.

00:47:38.460 --> 00:47:41.360
Get the full show notes over at Pythonbytes.fm.

00:47:41.360 --> 00:47:46.900
If you have a news item we should cover, just visit Pythonbytes.fm and click submit in the navbar.

00:47:46.900 --> 00:47:49.020
We're always on the lookout for sharing something cool.

00:47:49.440 --> 00:47:53.680
If you want to join us for the live recording, just visit the website and click live stream

00:47:53.680 --> 00:47:56.560
to get notified of when our next episode goes live.

00:47:56.560 --> 00:48:01.140
That's usually happening at noon Pacific on Wednesdays over at YouTube.

00:48:01.140 --> 00:48:04.620
On behalf of myself and Brian Okken, this is Michael Kennedy.

00:48:04.620 --> 00:48:08.340
Thank you for listening and sharing this podcast with your friends and colleagues.

