WEBVTT

00:00:00.001 --> 00:00:05.380
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.

00:00:05.380 --> 00:00:11.060
This is episode 306, recorded October 18th, 2022.

00:00:11.060 --> 00:00:12.140
I'm Michael Kennedy.

00:00:12.140 --> 00:00:13.440
And I'm Brian Oken.

00:00:13.440 --> 00:00:17.200
Very exciting to have a whole bunch of things to share this week.

00:00:17.200 --> 00:00:22.420
Also, I want to say thank you to Microsoft for startups for sponsoring yet another episode of this one.

00:00:22.420 --> 00:00:27.800
Brian, we've had a very long, dry summer here in Oregon.

00:00:28.300 --> 00:00:33.600
And I was afraid that we would have like terrible fires and it'd be all smoky and all sorts of badness.

00:00:33.600 --> 00:00:37.160
And there've been plenty of fires in the West, but not really around here for us this summer.

00:00:37.160 --> 00:00:39.500
We kind of dodged the bullet until like today.

00:00:39.500 --> 00:00:41.780
It's a little smoky today.

00:00:41.780 --> 00:00:44.080
We smoke, go inside.

00:00:44.080 --> 00:00:45.020
Yeah.

00:00:45.020 --> 00:00:46.620
I thought we dodged it, sadly.

00:00:46.620 --> 00:00:47.120
No.

00:00:47.120 --> 00:00:49.380
So I think it's affecting my voice a little bit.

00:00:49.380 --> 00:00:50.920
So apologies for that.

00:00:50.920 --> 00:00:55.060
We'll put that filter on you and we'll make you sound like someone else and you'll be fine.

00:00:55.060 --> 00:00:55.760
Yeah.

00:00:56.760 --> 00:00:57.200
Yeah.

00:00:57.200 --> 00:00:58.400
It's also affecting me.

00:00:58.400 --> 00:00:59.580
So who knows?

00:00:59.580 --> 00:01:03.000
But anyway, we'll make our way through.

00:01:03.000 --> 00:01:06.540
We will fight through the fire to bring you the Python news.

00:01:06.540 --> 00:01:09.120
Hopefully they get that actually put out soon.

00:01:09.120 --> 00:01:09.720
All right.

00:01:09.720 --> 00:01:10.180
The post office.

00:01:10.180 --> 00:01:10.980
Yeah.

00:01:10.980 --> 00:01:12.060
Let's kick it off.

00:01:12.060 --> 00:01:12.660
What's your first thing?

00:01:12.660 --> 00:01:15.500
So I've got, let's put it up.

00:01:15.500 --> 00:01:17.860
So I've got to stream.

00:01:18.320 --> 00:01:20.660
I've got awesome pytest speed up.

00:01:20.660 --> 00:01:21.940
So this is awesome.

00:01:21.940 --> 00:01:23.220
Yeah.

00:01:23.220 --> 00:01:28.900
So actually, some people may have noticed the testing code is not really going on lately.

00:01:28.900 --> 00:01:34.100
And so one of the things that makes it easier for me is when I see cool testing related articles,

00:01:34.100 --> 00:01:35.380
I don't have a decision anymore.

00:01:35.380 --> 00:01:37.240
I can just say, hey, it's going to go here.

00:01:37.240 --> 00:01:42.420
Now, testing code will eventually pick up something again, but I'm not sure when.

00:01:42.760 --> 00:01:46.500
So for now, if I find something cool like this article, I'll bring it up here.

00:01:46.500 --> 00:01:47.540
So this is.

00:01:47.540 --> 00:01:48.940
I think I make you show up every week.

00:01:48.940 --> 00:01:49.500
Yeah.

00:01:49.500 --> 00:01:50.460
Talk about fun stuff anyway.

00:01:50.460 --> 00:01:54.040
So this is a GitHub repo.

00:01:54.040 --> 00:01:59.660
And we're kind of seeing more of this of people writing instead of blogging.

00:01:59.660 --> 00:02:03.300
They just write like a readme as a repo.

00:02:03.300 --> 00:02:04.200
I know.

00:02:04.200 --> 00:02:05.500
This is such a weird trend.

00:02:05.500 --> 00:02:06.440
I totally get it.

00:02:06.440 --> 00:02:07.100
And it's good.

00:02:07.100 --> 00:02:08.200
But it's also weird.

00:02:08.200 --> 00:02:10.800
But it's kind of neat that people can update it.

00:02:10.880 --> 00:02:13.620
So if they can just keep it up and you can see people.

00:02:13.620 --> 00:02:13.860
That's right.

00:02:13.860 --> 00:02:15.460
You get a PR to your blog post.

00:02:15.460 --> 00:02:16.560
That's not normally how it goes.

00:02:16.560 --> 00:02:16.980
Yeah.

00:02:16.980 --> 00:02:18.700
So I'm not sure.

00:02:18.700 --> 00:02:23.080
But it's probably harder to throw Google Analytics at it, right?

00:02:23.080 --> 00:02:23.980
Oh, yeah.

00:02:23.980 --> 00:02:26.320
We'll see whether you should do that or not.

00:02:26.320 --> 00:02:31.320
So anyway, so this comes to us from Nate Zupan.

00:02:31.320 --> 00:02:33.120
Cool name, by the way.

00:02:34.000 --> 00:02:43.360
And he also has, we'll include a link in the show notes to a talk he gave at a plon in Namar 2022.

00:02:43.360 --> 00:02:45.040
So just recently.

00:02:45.040 --> 00:02:51.320
Anyway, so he goes through best practices to speed up your pytest suite.

00:02:52.700 --> 00:02:56.500
And he's just kind of lists them all at the top here, which is nice.

00:02:56.500 --> 00:02:58.460
Hardware first.

00:02:58.460 --> 00:03:02.820
Well, first of all, when he goes into the discussion, he talks about measuring first.

00:03:02.820 --> 00:03:10.040
So before you start speeding anything up, you should measure because you want to know if your changes had any effect.

00:03:10.040 --> 00:03:15.860
And if it's making support a little bit weirder, then you don't want to make the change if it's only marginal.

00:03:15.860 --> 00:03:23.260
So I like that he's talking about that of like each step of the way here, measure to make sure it makes a difference.

00:03:23.260 --> 00:03:23.780
Right.

00:03:23.780 --> 00:03:28.860
So first off, and I'm glad he brought this up, is check your hardware.

00:03:28.860 --> 00:03:33.860
Make sure you've got the fast hardware if you have it.

00:03:33.860 --> 00:03:39.240
So one of the, and I've noticed this before as well, is, so here we go, measure first.

00:03:40.480 --> 00:03:46.160
So some CI systems allow you to have self-hosted runners, and it's something to consider.

00:03:46.160 --> 00:03:57.980
The, whether your CI is in the cloud or you've got virtual, like a server with some virtual machines around to be able to run your test runners.

00:03:57.980 --> 00:04:03.280
They're not going to be as fast as physical hardware if you've got some hardware laying around that you can use.

00:04:03.280 --> 00:04:06.560
So that's something to consider to throw hardware at it.

00:04:06.700 --> 00:04:21.640
And then test collection time, some of the, some of the problems with the speed of pytest is using, if you've got, if you run it from the top level directory of a project and you've got tons of documentation and tons of source code, it's going to look everywhere.

00:04:21.640 --> 00:04:23.540
So don't let it look in those places.

00:04:23.540 --> 00:04:25.700
So there's, there's ways to turn that off.

00:04:25.700 --> 00:04:29.760
So with no recursive, so with no recursive, and giving it the directory.

00:04:29.760 --> 00:04:37.260
I also wanted to point out, he didn't talk about this in the article, but I want to point out that something to use is, oh, it went away.

00:04:37.260 --> 00:04:38.420
Test paths.

00:04:38.420 --> 00:04:41.680
So use test paths to say specifically.

00:04:41.680 --> 00:04:49.020
So the no recursive says essentially avoid these directories, but test paths pretty much says, this is where the tests are.

00:04:49.020 --> 00:04:49.540
Look here.

00:04:50.340 --> 00:04:51.540
So those are good.

00:04:51.540 --> 00:04:52.080
Nice.

00:04:52.080 --> 00:04:52.860
Yeah.

00:04:52.860 --> 00:05:00.260
I've done that before on some projects, like on the Talk Python Training website, where there's got a ton of text files and things laying around.

00:05:00.260 --> 00:05:13.260
And I've done certain things like that to exclude, you know, pytest and PyTarm and other, other different things to look there in those places where like, there's no code, but there's a ton of stuff here and you're going to go hunting through it.

00:05:13.260 --> 00:05:13.860
Yeah.

00:05:13.860 --> 00:05:21.800
So like, I really sped up the startup time for a pyramid scanning for files that have route definitions in them, right?

00:05:21.800 --> 00:05:22.900
For URL endpoints.

00:05:22.900 --> 00:05:24.020
Cause it would look through everything.

00:05:24.020 --> 00:05:25.280
Apparently doesn't matter.

00:05:25.280 --> 00:05:28.080
At least looking for files through directories with tons of stuff.

00:05:28.580 --> 00:05:32.300
And, and this is like, it makes a big difference if you have a large project for sure.

00:05:32.300 --> 00:05:32.760
Yeah.

00:05:32.760 --> 00:05:33.840
It's significant.

00:05:33.840 --> 00:05:36.160
So it was something to think about.

00:05:36.160 --> 00:05:38.040
And documentation too.

00:05:38.040 --> 00:05:41.820
You don't, unless you're really testing your documentation, you don't need to look there.

00:05:41.820 --> 00:05:45.240
So hardware fast, make collection fast.

00:05:45.240 --> 00:05:49.260
This one is something I haven't used before, but I'll play with it.

00:05:49.260 --> 00:05:53.120
Python don't write bytecode, a environmental flag.

00:05:54.620 --> 00:05:58.900
I guess it's, it, it comments that it might not make a big difference for you, but it might.

00:05:58.900 --> 00:06:02.500
So, you know, I don't know.

00:06:02.500 --> 00:06:08.040
So Python writes, writes the bytecode normally, and maybe it'd be faster if you didn't do that.

00:06:08.040 --> 00:06:10.460
What during tests, maybe we'll try.

00:06:10.840 --> 00:06:18.380
there's a way to disable py test plugins, to, yeah, let's just go built in py test plugins.

00:06:18.380 --> 00:06:22.180
You can say, no, like no nose or no doc test.

00:06:22.180 --> 00:06:22.880
If you're running those.

00:06:22.880 --> 00:06:27.940
I haven't noticed that it speeds it up a lot, but it's, again, it's something to try.

00:06:28.180 --> 00:06:30.980
And, and then a subset of tests.

00:06:30.980 --> 00:06:38.080
So, this is especially important if you're in a TDD style and that's, and one of the things

00:06:38.080 --> 00:06:42.920
that I think some people forget is your tech, if you've got your tests organized, well, you

00:06:42.920 --> 00:06:44.980
should be able to run a subset anyway.

00:06:44.980 --> 00:06:48.920
Cause you're, you've got like the feature you're working on is in a subdirectory of everything

00:06:48.920 --> 00:06:49.280
else.

00:06:49.580 --> 00:06:53.100
And just run those when you're working on that feature and then you don't run the whole

00:06:53.100 --> 00:06:53.380
suite.

00:06:53.380 --> 00:06:58.300
they talk, there's a discussion and this is, this goes along with the unit tests mostly,

00:06:58.300 --> 00:07:05.400
but, disable networking, unless you intending to have your code using networks, network

00:07:05.400 --> 00:07:05.920
connections.

00:07:05.920 --> 00:07:10.900
you can disable that for a set of tests or, or the whole suite.

00:07:10.900 --> 00:07:14.540
And then also disc access trying to limit that.

00:07:14.540 --> 00:07:18.820
And he includes a couple of ways to, to ensure those.

00:07:19.320 --> 00:07:25.100
and then, a really good discussion, a fairly chunky discussion on database access

00:07:25.100 --> 00:07:33.100
and optimization to databases, including discussion around, rollback and, and there was

00:07:33.100 --> 00:07:35.100
something else that I hadn't seen before.

00:07:35.100 --> 00:07:36.480
Let me see if I can remember.

00:07:36.480 --> 00:07:37.200
Yeah.

00:07:37.200 --> 00:07:38.160
There's some interesting things.

00:07:38.160 --> 00:07:43.700
I think, I know you've spoken about it in your pie test course about, using fixtures

00:07:43.700 --> 00:07:47.120
for like setup of, of those common, common type things.

00:07:47.120 --> 00:07:47.380
Right.

00:07:47.380 --> 00:07:49.060
So, so one of the things I w I'm not going to do with that.

00:07:49.060 --> 00:07:50.760
I am not familiar with is truncate.

00:07:50.760 --> 00:07:52.640
Have you used the database truncate before?

00:07:52.640 --> 00:07:53.280
No.

00:07:53.280 --> 00:07:59.120
So apparently that it allows you to set the whole database up, but delete all the stuff

00:07:59.120 --> 00:08:00.920
out of it, like the empty, the tables.

00:08:00.920 --> 00:08:08.540
and, and that, I mean, if, if part, if a big chunk of the work of setting up data

00:08:08.540 --> 00:08:12.680
is setting, getting all the tables correct, then truncate might be a good way to clean them

00:08:12.680 --> 00:08:14.960
out and then refill them if you need to.

00:08:14.960 --> 00:08:21.240
But, also, yeah, like you said, paying attention to, to fixtures, that's, it's really good.

00:08:21.240 --> 00:08:24.740
And then the last thing he brings up is just run them in parallel by default.

00:08:24.740 --> 00:08:28.460
pytest runs single each, each, test one at a time.

00:08:28.820 --> 00:08:34.360
And if you've got a code base that you're testing that can allow, like you're not testing a hardware

00:08:34.360 --> 00:08:39.440
resource or something, that you can allow parallel to go ahead and turn those on,

00:08:39.440 --> 00:08:43.260
turn on the, use xdst and turn or something else and run them in parallel.

00:08:43.540 --> 00:08:45.380
So, really good list.

00:08:45.380 --> 00:08:47.220
and I'm glad he put it together.

00:08:47.220 --> 00:08:48.640
Also very entertaining talk.

00:08:48.640 --> 00:08:50.720
So we'll give it, give his talk a look.

00:08:50.720 --> 00:08:52.460
Yeah, absolutely.

00:08:52.460 --> 00:08:56.780
Brandon out in the audience says people at work have been trying to convince me that

00:08:56.780 --> 00:09:01.120
tests should live next to the file they are testing rather than in a test directory.

00:09:01.120 --> 00:09:05.920
You know, I created a test directory that mirrors my app folder structure, with my test in there.

00:09:05.920 --> 00:09:06.700
Any opinions?

00:09:06.700 --> 00:09:09.980
I don't like that, but,

00:09:09.980 --> 00:09:11.380
Neither do I, honestly.

00:09:11.920 --> 00:09:13.240
If you like it, I guess.

00:09:13.240 --> 00:09:13.580
Okay.

00:09:13.580 --> 00:09:17.300
I've, I've heard that before, but I know I haven't heard people in Python recommending

00:09:17.300 --> 00:09:18.160
that very often.

00:09:18.160 --> 00:09:19.480
Yeah.

00:09:19.480 --> 00:09:23.240
For me, I feel, I understand why, like, okay, here's the code.

00:09:23.240 --> 00:09:24.260
Here's the test.

00:09:24.260 --> 00:09:30.400
Maybe, maybe the test can be exactly isolated to what is only in that file.

00:09:30.400 --> 00:09:34.580
But sometime, you know, like as soon as you start to blend together, like, okay, well,

00:09:34.580 --> 00:09:39.700
this thing works with that class to achieve its job.

00:09:39.700 --> 00:09:43.540
But it, you know, you kind of, it kind of starts to blur together and like, well, what

00:09:43.540 --> 00:09:44.640
if those are in the wrong places?

00:09:44.640 --> 00:09:46.300
Well, now it's like half here.

00:09:46.300 --> 00:09:47.360
And I don't know.

00:09:47.360 --> 00:09:51.640
It just, it, it leads to like lots of, I don't know.

00:09:51.640 --> 00:09:54.820
It's like trying to go to your IDE and say, I have these seven methods.

00:09:54.820 --> 00:09:55.920
Please write the test for it.

00:09:55.920 --> 00:09:58.880
And it says test function one, test function two, test function three.

00:09:58.880 --> 00:09:59.520
You're like, no, no, no.

00:09:59.520 --> 00:10:01.960
That is not really what you're after.

00:10:01.960 --> 00:10:04.440
But I feel it kind of leads, leads towards that.

00:10:04.440 --> 00:10:05.560
Like, well, here's the file.

00:10:05.560 --> 00:10:07.560
Let's test all the things in this file.

00:10:07.560 --> 00:10:10.060
And it, which is not necessarily the way I would think about testing.

00:10:10.060 --> 00:10:12.720
Well, also, are you really test?

00:10:12.720 --> 00:10:17.440
I mean, it kind of lends itself to starting to test the implementation instead of testing

00:10:17.440 --> 00:10:18.120
the behavior.

00:10:18.120 --> 00:10:19.000
Yes, exactly.

00:10:19.520 --> 00:10:23.460
Because you might have, if you've got a file that has no test associated with it,

00:10:23.460 --> 00:10:25.520
somebody might say, well, why is the test for that?

00:10:25.520 --> 00:10:28.760
And you're like, well, that file is just an implementation detail.

00:10:28.760 --> 00:10:33.140
It's not something we need to test because you, it's, you can't access it directly from the

00:10:33.140 --> 00:10:33.460
API.

00:10:33.460 --> 00:10:33.880
So.

00:10:33.880 --> 00:10:34.800
Right.

00:10:34.800 --> 00:10:37.280
It's completely covered by these two other, other tests.

00:10:37.280 --> 00:10:38.700
And by the way, there are other folders.

00:10:38.700 --> 00:10:39.560
Go find them.

00:10:39.560 --> 00:10:40.640
Yeah.

00:10:40.640 --> 00:10:46.600
Also the stuff you're speaking about here by like making collection fast and such also

00:10:46.600 --> 00:10:47.880
is a little bit tricky.

00:10:47.880 --> 00:10:51.540
Potentially sharing fixtures might be a little more tricky that way.

00:10:51.540 --> 00:10:52.220
I don't know.

00:10:52.220 --> 00:10:55.420
My, my vote is, is to not mix it all together.

00:10:55.420 --> 00:10:58.180
Plus, do you want to ship your test code with your product?

00:10:58.180 --> 00:11:00.160
Maybe you do, but often you don't.

00:11:00.160 --> 00:11:01.060
Is it harder?

00:11:01.060 --> 00:11:02.820
Harder if they're all woven together.

00:11:02.820 --> 00:11:03.620
That's true.

00:11:03.620 --> 00:11:04.080
Yeah.

00:11:04.080 --> 00:11:05.480
Yeah.

00:11:05.480 --> 00:11:08.880
So anyway, that's the same thing.

00:11:08.880 --> 00:11:12.420
Also, Henry Schreiner out there kind of says, I don't like distributing tests in wheels

00:11:12.420 --> 00:11:13.300
on the Estes.

00:11:13.300 --> 00:11:14.680
So like a test folder as well.

00:11:14.680 --> 00:11:15.000
Yeah.

00:11:15.000 --> 00:11:15.980
I'm with you.

00:11:16.520 --> 00:11:22.580
I think Brandon, the vote here is test folder, but you know, that's just, just us.

00:11:22.580 --> 00:11:23.300
Yeah.

00:11:23.300 --> 00:11:24.800
Awesome.

00:11:24.800 --> 00:11:25.740
All right.

00:11:25.740 --> 00:11:26.860
Well, this is, yeah, that's a good find.

00:11:26.860 --> 00:11:28.320
You want to hear my first one?

00:11:28.320 --> 00:11:30.580
This is a, this is a bit of a journey.

00:11:30.580 --> 00:11:31.720
It's a bit of a journey.

00:11:31.720 --> 00:11:33.580
So let's start here.

00:11:33.580 --> 00:11:41.020
So I have a perfectly fine laptop that I can take places if I need to for work.

00:11:41.020 --> 00:11:42.940
Take it to the coffee shop to work.

00:11:42.940 --> 00:11:46.600
If I'm going on like a two week vacation, it's definitely coming with me.

00:11:46.600 --> 00:11:47.300
Right.

00:11:47.300 --> 00:11:52.940
It's even if my intent is to completely disconnect, I still have to answer super urgent emails.

00:11:52.940 --> 00:11:59.120
If the website goes down, any of the many websites I seem to be babysitting these days,

00:11:59.120 --> 00:12:00.540
like I've got to work on it.

00:12:00.540 --> 00:12:02.420
Like there could be urgent stuff.

00:12:02.420 --> 00:12:02.580
Right.

00:12:02.580 --> 00:12:06.440
So I just, I take it with me, but I'm on this mission to do that less.

00:12:06.440 --> 00:12:07.020
Right.

00:12:07.020 --> 00:12:09.240
Cause I have a 16 inch MacBook pro.

00:12:09.240 --> 00:12:09.960
It's pretty heavy.

00:12:09.960 --> 00:12:10.900
It's pretty expensive.

00:12:10.900 --> 00:12:15.460
I don't necessarily want to like take it camping with me, but what if, what if something goes

00:12:15.460 --> 00:12:16.040
wrong, Brian?

00:12:16.040 --> 00:12:17.160
What if I got to fix it?

00:12:17.160 --> 00:12:19.240
Do I really want to drive the four hours back?

00:12:19.240 --> 00:12:23.040
Because I got a message that like, you know, the website's down and everyone's upset.

00:12:23.040 --> 00:12:25.340
Can't do their courses or they can't get the podcast.

00:12:25.340 --> 00:12:26.580
No, I don't want that.

00:12:26.580 --> 00:12:29.580
So I would probably take the stupid thing and try to not get it wet.

00:12:29.580 --> 00:12:32.340
So I'm on this mission to not do that.

00:12:32.340 --> 00:12:35.740
So I just wanted to share a couple of tools and, you know, people, if they've got thoughts,

00:12:35.740 --> 00:12:40.960
I guess probably the YouTube stream chat for this to be the best or on Twitter, they could

00:12:40.960 --> 00:12:41.660
let me know.

00:12:41.660 --> 00:12:46.600
But I think I found like the right combination of tools that will let me just take my iPad

00:12:46.600 --> 00:12:51.040
and still do all the dev opsy life that I got to lead.

00:12:51.040 --> 00:12:51.560
Okay.

00:12:51.560 --> 00:12:53.540
So that it's not good for answering emails.

00:12:53.820 --> 00:12:58.120
You know, I have like minor RSI issues and I can't type on an iPad, not even a little

00:12:58.120 --> 00:12:59.500
like keyboard that comes with it.

00:12:59.500 --> 00:13:06.080
Like I've got my proper Microsoft ergonomic sculpt and you can plug that into an iPad.

00:13:06.080 --> 00:13:09.040
But once you start taking that, you know, like, well, you might as well just take the computer.

00:13:09.040 --> 00:13:15.760
So, two tools I want to give a shout out to prompt by panic panic is a Portland company.

00:13:15.760 --> 00:13:17.320
So shout out to the local team.

00:13:17.320 --> 00:13:19.400
Is it at the disco or?

00:13:19.400 --> 00:13:21.180
Exactly.

00:13:21.180 --> 00:13:23.100
They don't really freak out that much at the disco.

00:13:23.100 --> 00:13:23.540
Okay.

00:13:23.540 --> 00:13:24.360
I don't even panic there.

00:13:24.360 --> 00:13:30.740
but prompt is a SSH client for iOS in particular for iPad, but you could, I mean, if you wanted

00:13:30.740 --> 00:13:34.260
to go extreme, you could do this on your phone, you know, how, how far are you going camping,

00:13:34.260 --> 00:13:34.560
right?

00:13:34.560 --> 00:13:35.600
Or where, where are you going?

00:13:35.600 --> 00:13:42.400
And so this lets you basically import your SSH keys and do full on SSH.

00:13:42.600 --> 00:13:47.040
SSH like you would in your, I term to, or, or terminal or whatever.

00:13:47.040 --> 00:13:48.420
Turns your iPad into a dump terminal.

00:13:48.420 --> 00:13:49.020
Yeah.

00:13:49.020 --> 00:13:49.480
And it does.

00:13:49.480 --> 00:13:57.020
So like you can easily log into, you know, the Python bytes server and over SSH do all the

00:13:57.020 --> 00:13:57.900
things that you need to do.

00:13:58.040 --> 00:14:00.940
So, you know, you've got to get into the server and you've got to like, okay, well, I really

00:14:00.940 --> 00:14:04.020
have to just go restart the stupid thing or change a connection string.

00:14:04.020 --> 00:14:05.420
Cause who knows what, right?

00:14:05.420 --> 00:14:07.260
You could, you do it.

00:14:07.260 --> 00:14:08.600
It seems to work pretty well.

00:14:08.600 --> 00:14:14.780
The only complaint, the only complaint that I have for it is it doesn't have, nerd

00:14:14.780 --> 00:14:15.140
fonts.

00:14:15.600 --> 00:14:18.040
So my, oh my posh, dude, this is serious business.

00:14:18.040 --> 00:14:18.560
Don't laugh.

00:14:18.560 --> 00:14:21.440
My nerd fonts, my, like, I can't do PLS.

00:14:21.440 --> 00:14:28.100
I can't do, oh my posh and get like the cool, like shell prompt with all the information.

00:14:28.100 --> 00:14:29.640
No, it's all just boxes.

00:14:29.640 --> 00:14:30.680
It's rough.

00:14:30.680 --> 00:14:31.600
No, it's fine.

00:14:31.600 --> 00:14:33.840
It would be nice, but it does have cool things.

00:14:33.840 --> 00:14:39.540
Like if you need to press control shift that, or, you know, it has like a special way to pull

00:14:39.540 --> 00:14:41.500
up the, all those kinds of keys.

00:14:41.500 --> 00:14:45.000
So you press control and then some other type of thing, or, you know, it has up arrow down

00:14:45.000 --> 00:14:45.320
areas.

00:14:45.320 --> 00:14:48.960
Like if you want to cycle through your history, it's got a, it's got a lot of cool features

00:14:48.960 --> 00:14:52.340
like that where, you can kind of integrate that.

00:14:52.340 --> 00:14:52.740
So it works.

00:14:52.740 --> 00:14:53.500
I think it's going to work.

00:14:53.500 --> 00:14:56.440
I think this is the one half of the DevOps story.

00:14:56.440 --> 00:14:57.720
Okay.

00:14:57.720 --> 00:14:59.940
The other, the other part is, oh my goodness.

00:14:59.940 --> 00:15:02.220
What if it's a code problem?

00:15:02.220 --> 00:15:09.080
Do I really want to try to edit code over this prompt thing through the iPad on, you know,

00:15:09.080 --> 00:15:11.380
in like Emacs or what am I getting?

00:15:11.380 --> 00:15:12.260
No, I don't want to do that.

00:15:12.700 --> 00:15:20.300
So the other half is GitHub in particular, the VS Code integration into GitHub.

00:15:20.300 --> 00:15:25.760
So if you remember, like here I have pulled up on the screen, just with any public repo

00:15:25.760 --> 00:15:26.740
or your own private ones.

00:15:27.120 --> 00:15:33.660
This is my Jinja partial thing for like basically integrating HTMX with a flask, but you can

00:15:33.660 --> 00:15:34.340
press the dot.

00:15:34.340 --> 00:15:41.180
If you press dot, it turns that whole thing into a cloud hosted VS Code session.

00:15:41.180 --> 00:15:42.020
That's awesome.

00:15:42.020 --> 00:15:42.220
Right.

00:15:42.260 --> 00:15:43.080
Even has autocomplete.

00:15:43.080 --> 00:15:46.420
So if I hit like dot there, you can see it's on my autocomplete.

00:15:46.420 --> 00:15:47.420
That's pretty cool.

00:15:47.420 --> 00:15:48.340
That's pretty cool.

00:15:48.340 --> 00:15:55.600
But how do you press dot when you're on a webpage and, and iPad, there is no dot because you

00:15:55.600 --> 00:15:56.700
can't pull up the keyboard.

00:15:56.700 --> 00:15:59.100
The only thing you can do, pull up the keyboard is go to an input section.

00:15:59.100 --> 00:16:01.020
And once you're in input, well, that just types dot.

00:16:01.020 --> 00:16:01.680
It doesn't do that.

00:16:01.680 --> 00:16:02.920
You're like, why?

00:16:03.180 --> 00:16:04.880
So here's the other piece.

00:16:04.880 --> 00:16:05.220
All right.

00:16:05.220 --> 00:16:05.820
Here's the other piece.

00:16:05.820 --> 00:16:10.040
So you go over here and you change github.com/Mike C. Kennedy slash Jinja partial to

00:16:10.040 --> 00:16:12.400
github.com/dev slash whatever.

00:16:12.400 --> 00:16:12.960
Boom.

00:16:12.960 --> 00:16:13.440
Done.

00:16:13.440 --> 00:16:18.940
So if you got to edit your code, you just go change the dot com to dot dev and you have an

00:16:18.940 --> 00:16:19.220
editor.

00:16:19.220 --> 00:16:20.380
You can check it back in.

00:16:20.380 --> 00:16:25.580
Like in my setup, if I commit to the production branch, it kicks off a continuous deployment,

00:16:25.580 --> 00:16:30.620
which will like automatically restart the server and reinstall like the things that might

00:16:30.620 --> 00:16:30.840
need.

00:16:30.840 --> 00:16:35.420
like if it has a new dependency or something, I could literally just come over here, make

00:16:35.420 --> 00:16:39.580
some changes, do a PR over to the production branch or push some how much over to the production

00:16:39.580 --> 00:16:41.040
branch and it's done.

00:16:41.040 --> 00:16:41.600
It's good to go.

00:16:41.600 --> 00:16:42.380
Isn't that awesome?

00:16:42.380 --> 00:16:43.780
Just edit live.

00:16:43.780 --> 00:16:45.880
Just, you know, edit your server live.

00:16:45.880 --> 00:16:46.580
No.

00:16:46.580 --> 00:16:47.520
Yeah.

00:16:47.520 --> 00:16:52.000
I saw somewhere, somebody was complaining about the, prompt saying it's really hard for

00:16:52.000 --> 00:16:53.520
me to edit my code on the server.

00:16:53.520 --> 00:16:56.840
I'm like, why, why would you know it should be hard.

00:16:56.840 --> 00:16:57.640
You don't do that.

00:16:57.640 --> 00:16:58.500
Don't do that.

00:16:58.500 --> 00:16:59.660
Yeah.

00:16:59.860 --> 00:17:04.520
So I went to try to try this, but I have to do the two factor authentication to get

00:17:04.520 --> 00:17:05.260
into my account.

00:17:05.260 --> 00:17:06.240
So, yeah.

00:17:06.240 --> 00:17:06.840
Yeah.

00:17:06.840 --> 00:17:07.040
Yeah.

00:17:07.040 --> 00:17:07.560
You got to do that.

00:17:07.560 --> 00:17:10.340
Brandon also says, Hey, I'll buy you a keyboard case.

00:17:10.340 --> 00:17:11.820
I absolutely hear you.

00:17:11.820 --> 00:17:16.280
And I would love, you have no idea how jealous I am of people that can go and type on their

00:17:16.280 --> 00:17:18.880
laptops and type on these small things like RSI.

00:17:18.880 --> 00:17:22.240
I would be, I would be destroyed in like an hour or two.

00:17:22.240 --> 00:17:25.520
If I did it, it's like, it's not a matter of, do I want to get the keyboard?

00:17:25.600 --> 00:17:27.240
Like I just can't.

00:17:27.240 --> 00:17:32.900
So anyway, it's not that bad to be me, but I'm not, I'm not typing on like small square

00:17:32.900 --> 00:17:33.240
keyboards.

00:17:33.240 --> 00:17:33.940
It just doesn't work.

00:17:33.940 --> 00:17:34.880
It's just something I can't do.

00:17:34.880 --> 00:17:35.700
Okay.

00:17:35.700 --> 00:17:40.300
So just, exactly.

00:17:40.300 --> 00:17:45.660
No, I just, I like, because when I was 30, my hands got messed up and they just, they

00:17:45.660 --> 00:17:47.280
almost recovered, but not a hundred percent.

00:17:47.280 --> 00:17:47.580
Right.

00:17:47.820 --> 00:17:49.780
So I know you got more going on than I do though.

00:17:49.780 --> 00:17:53.220
So I just got back from four days off and I took the iPad.

00:17:53.220 --> 00:18:01.740
And I had to answer a few emails, but the, for me, these short emails, the little

00:18:01.740 --> 00:18:04.240
key bed, the cover thing and it works fine.

00:18:04.240 --> 00:18:09.140
Even though they're, those are expensive when you add, well, I want an iPad, but I also want

00:18:09.140 --> 00:18:10.760
the, the keyboard thing.

00:18:10.760 --> 00:18:11.780
And I want the pencil.

00:18:11.780 --> 00:18:14.680
Suddenly it's like almost twice as much.

00:18:14.680 --> 00:18:15.380
It is.

00:18:15.380 --> 00:18:15.860
It is.

00:18:15.920 --> 00:18:16.220
Absolutely.

00:18:16.220 --> 00:18:21.700
And you know, just, people are, who've been paying attention for the last two hours.

00:18:21.700 --> 00:18:23.860
Apple just released new iPads with M2s.

00:18:23.860 --> 00:18:25.760
So people can go check that out if they want to spend money.

00:18:25.760 --> 00:18:27.080
I'm happy with mine.

00:18:27.080 --> 00:18:27.800
I'm going to keep it.

00:18:27.800 --> 00:18:28.140
All right.

00:18:28.140 --> 00:18:30.540
Before we move on to the next thing, Brian.

00:18:30.540 --> 00:18:31.380
Okay.

00:18:31.380 --> 00:18:33.460
Let me tell you about our sponsor this week.

00:18:33.460 --> 00:18:36.720
So as has been the case as usual, thank you so much.

00:18:36.720 --> 00:18:41.000
Microsoft for startups founders hub is sponsoring this episode.

00:18:41.000 --> 00:18:44.800
We all know that starting a business is hard by a lot of estimates.

00:18:44.800 --> 00:18:48.280
Over 90% of startups go out of business in just the first year.

00:18:48.280 --> 00:18:49.720
And there's a lot of reasons for that.

00:18:49.720 --> 00:18:52.660
Is it that you don't have the money to buy the resources?

00:18:52.660 --> 00:18:54.280
Can you not scale fast enough?

00:18:54.280 --> 00:18:59.680
Often it's like you have the wrong strategy or do you not have the right connections to,

00:18:59.680 --> 00:19:02.900
you know, get the right publicity or you have no experience in marketing?

00:19:02.900 --> 00:19:06.540
Lots, lots of problems, lots of challenges.

00:19:06.780 --> 00:19:13.000
And as software developers, we're often not trained in those necessary areas like marketing,

00:19:13.000 --> 00:19:13.540
for example.

00:19:13.540 --> 00:19:15.480
But even if you know that, like there's others, right?

00:19:15.480 --> 00:19:21.540
So having access to a network of founders, like you get in a lot of accelerators, like Y Combinator,

00:19:21.540 --> 00:19:22.600
would be awesome.

00:19:22.940 --> 00:19:25.780
So that's what Microsoft created with their founders hub.

00:19:25.780 --> 00:19:32.660
So they give you free resources to a whole bunch of cloud things, Azure, GitHub, others,

00:19:32.660 --> 00:19:40.380
as well as very importantly, access to a mentor network where you can book one-on-one calls with people

00:19:40.380 --> 00:19:43.420
who have experience in these particular areas.

00:19:43.580 --> 00:19:47.900
Often many of them are founders themselves and they've created startups and sold them

00:19:47.900 --> 00:19:50.000
and they're in this mentorship network.

00:19:50.000 --> 00:19:56.020
So if you want to talk to somebody about idea validation, fundraising, management and coaching,

00:19:56.020 --> 00:20:00.140
sales and marketing, all those things, you can book one-on-one meetings with these people

00:20:00.140 --> 00:20:02.600
to help get you going and make connections.

00:20:02.600 --> 00:20:08.720
So if you need some free GitHub and Microsoft cloud resources, if you need access to mentors

00:20:08.720 --> 00:20:12.660
and you want to get your startup going, make your idea a reality today

00:20:12.660 --> 00:20:15.160
with the support from Microsoft for startups, founders hub.

00:20:15.160 --> 00:20:16.560
It's free to join.

00:20:16.560 --> 00:20:18.460
It doesn't have to be venture backed.

00:20:18.460 --> 00:20:20.400
It doesn't have to be third-party validated.

00:20:20.400 --> 00:20:25.880
You just apply for free at pythonbiz.fm slash founders hub 2022.

00:20:25.880 --> 00:20:27.380
The link is in your show notes.

00:20:27.380 --> 00:20:31.460
Thanks a bunch to Microsoft for sponsoring our show.

00:20:31.460 --> 00:20:32.580
What's next, Brian?

00:20:32.580 --> 00:20:36.500
Well, that article that I already read about the speeding up pytest,

00:20:36.500 --> 00:20:38.840
it had a whole bunch of cool tools in it.

00:20:38.840 --> 00:20:41.740
So I wanted to go through some of the tools that were in the article

00:20:41.740 --> 00:20:42.800
that I thought were neat.

00:20:42.800 --> 00:20:47.380
One of them for profiling and timing was a thing called Hyperfine.

00:20:47.380 --> 00:20:53.360
And this is a not, I don't think it's a Python thing, but you like for max,

00:20:53.360 --> 00:20:54.420
you had to brew install it.

00:20:55.580 --> 00:21:02.900
But one of the things it does is you can give it, you give it like two things and it runs both of them

00:21:02.900 --> 00:21:08.500
and it can run it multiple times and then give you statistics comparing them.

00:21:08.500 --> 00:21:14.680
So it's a really good comparison tool to, you know, like if you're testing your test suite to see how long it runs.

00:21:15.220 --> 00:21:17.500
May as well run it a couple of times and see.

00:21:17.500 --> 00:21:18.840
Yeah.

00:21:18.840 --> 00:21:23.960
And for people who didn't see yet the example from that first article you covered,

00:21:23.960 --> 00:21:26.840
a lot of those were CLI flags, right?

00:21:26.840 --> 00:21:32.140
Like dash, dash, no, no's for disabling the plugin and so on.

00:21:32.140 --> 00:21:38.320
So you could have two commands on the command line where you like basically change the command line arguments

00:21:38.320 --> 00:21:40.540
to determine those kinds of things, right?

00:21:40.540 --> 00:21:41.100
Yeah.

00:21:41.100 --> 00:21:42.300
Like, yeah, exactly.

00:21:42.300 --> 00:21:46.300
So run it a couple of times and run it, run the test suite a couple of times each

00:21:46.300 --> 00:21:53.420
and just to see if I add the, if it had these no flags or this other flag or with the environmental variable.

00:21:53.420 --> 00:21:55.800
Actually, I don't know how you could do that in there.

00:21:55.800 --> 00:21:58.220
You can set environmental variables in the command line maybe.

00:21:58.220 --> 00:21:59.980
Yeah, I'm sure that you can somehow.

00:21:59.980 --> 00:22:00.560
Yeah.

00:22:00.560 --> 00:22:03.380
In line an export statement or something, who knows?

00:22:03.380 --> 00:22:06.340
At the very least, you can run the same command twice.

00:22:06.340 --> 00:22:10.860
You can run it, set the environmental variable and then run it again to see if it makes a difference.

00:22:10.860 --> 00:22:11.780
So, yeah.

00:22:11.780 --> 00:22:13.400
So that, that was neat.

00:22:14.760 --> 00:22:16.840
I don't know why I've got the API reference in here.

00:22:16.840 --> 00:22:20.700
Oh, the thing I wanted to talk about was durations.

00:22:20.700 --> 00:22:21.840
So let me find that.

00:22:21.840 --> 00:22:22.980
I think I lost it.

00:22:22.980 --> 00:22:26.680
So we did talk about duration, durations.

00:22:26.680 --> 00:22:27.960
Oh, well.

00:22:27.960 --> 00:22:29.100
Oh, here it is.

00:22:29.100 --> 00:22:34.240
So durations, if you give it a number, it like durations 10, it, pytest will give you like

00:22:34.240 --> 00:22:37.540
the 10 slowest tests and tell you how far, how slow they are.

00:22:37.540 --> 00:22:40.440
But you can, if you don't give it anything, it just does all of it.

00:22:40.440 --> 00:22:46.800
But the other thing that's been fairly recent, it wasn't there when I started using

00:22:46.800 --> 00:22:48.220
pytest is durations min.

00:22:48.220 --> 00:22:55.520
So you can, you can give it, when you give it durations with a blank or in zero, it, it

00:22:55.520 --> 00:22:58.680
times everything, but you can, but that might be overwhelming.

00:22:58.680 --> 00:23:04.880
So you can give it a minimum duration in seconds to only include only time the tests are all

00:23:04.880 --> 00:23:06.600
over a second or something like that.

00:23:06.600 --> 00:23:07.200
Right.

00:23:07.200 --> 00:23:07.600
Right.

00:23:07.600 --> 00:23:12.000
It was really, if it's 25 milliseconds, like just, I don't want to see it.

00:23:12.000 --> 00:23:12.380
Yeah.

00:23:12.580 --> 00:23:15.320
I'm not going to spend time trying to speed that up, but yeah.

00:23:15.320 --> 00:23:22.640
Another cool thing brought up was a pie instrument, which is a way to, it's a very pretty way to

00:23:22.640 --> 00:23:26.140
look at, you know, the times that you're spending on different things.

00:23:26.140 --> 00:23:28.800
It's not just for testing, but you could use it for other stuff.

00:23:28.800 --> 00:23:34.440
But apparently there's a, in the user guide, there is specifically how to profile your tests

00:23:34.440 --> 00:23:36.580
with pytest using pie instrument.

00:23:36.580 --> 00:23:39.300
So that's a cool, cool bit of documentation.

00:23:39.300 --> 00:23:41.480
This doesn't, and this doesn't actually look obvious.

00:23:41.480 --> 00:23:46.720
So maybe I'm, maybe I'm looking at this wrong, but I'm glad, I'm glad, I'm glad they wrote

00:23:46.720 --> 00:23:47.140
this up.

00:23:47.140 --> 00:23:48.920
So this is kind of cool.

00:23:48.920 --> 00:23:51.920
Basically profiling your, oh, interesting.

00:23:51.920 --> 00:23:53.860
And you do it as a fixture.

00:23:53.860 --> 00:23:54.720
Yeah.

00:23:54.720 --> 00:24:01.360
And so you create the profiler, you start the profiler, then you yield nothing, which triggers

00:24:01.360 --> 00:24:02.020
the test to run.

00:24:02.020 --> 00:24:03.840
And then you stop the profiler and do the output.

00:24:03.840 --> 00:24:04.860
That's really cool.

00:24:04.860 --> 00:24:05.580
Yeah.

00:24:05.580 --> 00:24:06.820
Pretty cool way to do that.

00:24:06.820 --> 00:24:08.260
So profiling each test.

00:24:08.260 --> 00:24:08.920
Yeah.

00:24:08.920 --> 00:24:09.040
Yeah.

00:24:10.120 --> 00:24:12.280
It's a bit mind bending on the coroutines.

00:24:12.280 --> 00:24:13.960
So it's kind of cool.

00:24:13.960 --> 00:24:19.640
They're using it as a fixture because if you had the fixtures set up as a, like it's set

00:24:19.640 --> 00:24:20.920
up by default as a function.

00:24:20.920 --> 00:24:22.160
So it'll go around every function.

00:24:22.160 --> 00:24:27.320
But if you set it up as a module, you could just find the slow module test modules in your

00:24:27.320 --> 00:24:30.780
system, which might be an easier way to speed things up.

00:24:30.780 --> 00:24:31.180
If you're looking.

00:24:31.180 --> 00:24:31.660
Anyway.

00:24:31.660 --> 00:24:39.560
Oh, I was thrilled that my little pytest skip slow plugin that I developed as part of it.

00:24:39.560 --> 00:24:45.140
I didn't even come up with the ideas for the code, but that came out of the pytest documentation,

00:24:45.140 --> 00:24:46.320
but it wasn't a plugin yet.

00:24:46.320 --> 00:24:52.440
But I developed this plugin during writing the second edition of the book and it showed up

00:24:52.440 --> 00:24:53.700
in his article, which is cool.

00:24:54.740 --> 00:24:59.180
More interesting is pytest socket, which is a plugin that can turn off.

00:24:59.180 --> 00:25:03.180
It just turns off a socket Python socket calls.

00:25:05.300 --> 00:25:08.500
And, and then it raises a particular exception.

00:25:08.500 --> 00:25:12.220
So it doesn't like if you just install it, it doesn't turn things off.

00:25:12.220 --> 00:25:18.640
You have to pass in a disable socket to your test suite and then it turns off accessing the

00:25:18.640 --> 00:25:19.520
external world.

00:25:19.520 --> 00:25:25.320
So this is a kind of a cool way to easily find out which tests are failing because your network

00:25:25.320 --> 00:25:26.500
is not connected.

00:25:26.500 --> 00:25:31.080
So go figure out if you want to say, definitely don't talk to the network or don't talk to

00:25:31.080 --> 00:25:31.660
the database.

00:25:31.660 --> 00:25:33.680
Turn off the network and see what happens.

00:25:34.180 --> 00:25:34.380
Yeah.

00:25:34.380 --> 00:25:37.980
And then you can, I mean, but even if you did want part of your test suite to access the

00:25:37.980 --> 00:25:41.680
network, you could test it to make sure that there aren't other parts of your test suite

00:25:41.680 --> 00:25:43.720
that are accessing it when they shouldn't.

00:25:43.720 --> 00:25:45.540
So it'd be cool debugging.

00:25:45.540 --> 00:25:47.780
And then file system stuff too.

00:25:47.780 --> 00:25:52.340
There's probably fake FS, fake file system that you can mock a file system.

00:25:52.340 --> 00:25:56.380
So even things that you want to write, you don't actually have to have the files left around.

00:25:56.380 --> 00:25:58.680
You can leave them around just long enough to test them.

00:25:58.680 --> 00:25:59.480
So you can use this.

00:25:59.480 --> 00:26:00.200
That's perfect.

00:26:00.200 --> 00:26:04.160
And then the last thing I thought was cool was a way there's a thing called blue racer.

00:26:04.160 --> 00:26:13.160
that, that you can attach to a get, GitHub, CI to check, to check in merges.

00:26:13.160 --> 00:26:15.160
So if somebody merges something, you can test it.

00:26:15.160 --> 00:26:18.180
You can check to see if they've terribly slowed down your test suite.

00:26:18.180 --> 00:26:24.620
so it kind of reports that it doesn't, I don't think it fails on slower tests, but it

00:26:24.620 --> 00:26:28.800
just sort of reports, reports what's going on.

00:26:28.800 --> 00:26:34.340
So yeah, it gives you a little report of like, the nice what happened on the branch and

00:26:34.340 --> 00:26:35.740
if the test suite slowed down.

00:26:35.740 --> 00:26:37.040
So yeah, thanks to know.

00:26:37.040 --> 00:26:37.460
Yeah.

00:26:37.460 --> 00:26:38.540
That's a cool project.

00:26:38.540 --> 00:26:39.320
blue racer.

00:26:39.320 --> 00:26:39.900
Nice.

00:26:39.960 --> 00:26:40.200
Okay.

00:26:40.200 --> 00:26:42.340
And it's automatic, which is lovely.

00:26:42.340 --> 00:26:43.600
Yeah.

00:26:43.600 --> 00:26:45.520
So nice.

00:26:45.520 --> 00:26:46.160
All right.

00:26:46.160 --> 00:26:48.920
Well, I've got one more item for us as well, Brian.

00:26:49.140 --> 00:26:49.380
Yay.

00:26:49.380 --> 00:26:55.300
So we talked a little bit about, you talked about PI upgrade, the last show, I think

00:26:55.300 --> 00:26:55.700
it was.

00:26:55.700 --> 00:26:56.120
Yeah.

00:26:56.120 --> 00:26:58.240
And we talked about some of these other ones.

00:26:58.240 --> 00:27:02.840
So I want to talk about, I'm going to give a shout out to refurb, very active project last

00:27:02.840 --> 00:27:06.920
updated two days ago, 1,600 stars.

00:27:06.920 --> 00:27:12.140
And the idea is basically you can point this at your code and it'll just say, here are

00:27:12.140 --> 00:27:15.660
the things that are making it seem like the old way of doing things.

00:27:15.660 --> 00:27:18.120
You should try doing it the newer way.

00:27:18.120 --> 00:27:24.740
So, for example, here's something, it's, it's asking if the file name is in a list,

00:27:24.740 --> 00:27:25.340
right?

00:27:25.340 --> 00:27:30.340
The, one of the ways you can see if, if file name equals X or file name equals Y or file

00:27:30.340 --> 00:27:35.420
name equals Z, you can say if file name in X comma Y or comma Z, right?

00:27:35.420 --> 00:27:39.580
And that's a more concise and often considered more Pythonic way.

00:27:39.580 --> 00:27:42.860
But do you need a whole list allocated just to ask that question?

00:27:42.860 --> 00:27:43.760
What about a tuple?

00:27:43.760 --> 00:27:49.340
And here we have a with open file name as F then contents F dot read.

00:27:49.340 --> 00:27:51.120
And then we have the split lines and so on.

00:27:51.120 --> 00:27:55.820
And so, well, if you're using path lib, just say path dot read text.

00:27:55.820 --> 00:27:57.540
You don't need the context manager.

00:27:57.540 --> 00:27:58.880
You don't need two lines.

00:27:58.880 --> 00:28:00.100
Just do it all in one.

00:28:00.100 --> 00:28:05.300
And so on this simple little bit of code here, they just run refurb against your, this example,

00:28:05.300 --> 00:28:06.280
Python file.

00:28:06.280 --> 00:28:12.860
And it'll say, use duple X, Y, Z instead of list X, Y, Z for that in case.

00:28:12.860 --> 00:28:17.000
And then what I really like about it is it finds like exactly the pattern that you're doing.

00:28:17.000 --> 00:28:24.800
So it says you're using with open something as F, then value equals F dot read use,

00:28:24.800 --> 00:28:29.080
you know, value equals path of X dot read text one line.

00:28:29.080 --> 00:28:32.640
It gives you like pretty, it doesn't say you should use path read text.

00:28:32.640 --> 00:28:37.840
It gives you in the syntax of here's the multiple lines you did do this instead.

00:28:37.840 --> 00:28:39.420
Nice, right?

00:28:39.620 --> 00:28:41.860
I don't, I don't think I've ever used read text.

00:28:41.860 --> 00:28:42.980
So I learned something new.

00:28:42.980 --> 00:28:44.840
I hadn't either, but you know what I do now.

00:28:44.840 --> 00:28:52.920
It also says you can replace X starts with Y or starts with Z with, starts with X,

00:28:52.920 --> 00:28:54.880
you know, or Y comma Z as a tuple.

00:28:54.980 --> 00:28:58.660
And that'll actually test, yeah, one of the other.

00:28:58.660 --> 00:28:59.220
Okay.

00:28:59.220 --> 00:29:03.100
It says, instead of printing with an empty string, there's no reason to allocate an empty string.

00:29:03.100 --> 00:29:04.420
Just call print blank.

00:29:04.420 --> 00:29:05.480
That does the same effect.

00:29:05.480 --> 00:29:08.820
And just, there's a whole bunch of things like that, that are really nice here.

00:29:08.820 --> 00:29:12.300
And yeah, just, you can ask it to explain.

00:29:12.300 --> 00:29:13.960
You're like, dude, what's going on here?

00:29:14.060 --> 00:29:16.080
it told you told me to do one, two, three.

00:29:16.080 --> 00:29:19.020
what, what's the motivation?

00:29:19.020 --> 00:29:20.420
And you'll get kind of like a help text.

00:29:20.420 --> 00:29:21.300
Here's the bad version.

00:29:21.300 --> 00:29:22.120
Here's the good version.

00:29:22.120 --> 00:29:23.520
Here's why you might consider that.

00:29:23.520 --> 00:29:28.840
So for example, given a string, don't cast it again to a string, just use it.

00:29:28.840 --> 00:29:32.100
maybe more important as you can ignore errors.

00:29:32.100 --> 00:29:35.740
So you can ignore, just do a dash, dash, ignore a number.

00:29:35.740 --> 00:29:41.060
There's one, which I'll show you in a second, which I've started adopting that for when I use

00:29:41.060 --> 00:29:42.740
it, or you can put a hash, no QA.

00:29:43.060 --> 00:29:46.400
And put a particular warning to be disabled.

00:29:46.400 --> 00:29:49.060
Or you can just say, no, just leave this line alone.

00:29:49.060 --> 00:29:49.980
Like, I just don't want to hear it.

00:29:49.980 --> 00:29:51.120
Don't tell me.

00:29:51.120 --> 00:29:52.940
so as you can say, hash, no QA.

00:29:52.940 --> 00:29:55.100
And then it won't, it'll catch like all of them.

00:29:55.100 --> 00:29:55.680
Okay.

00:29:55.680 --> 00:29:56.280
Okay.

00:29:56.280 --> 00:30:00.320
So I ran this on the Python bytes website and we got this.

00:30:00.320 --> 00:30:06.180
It says, there's a part where it like builds up a list and then take some things out

00:30:06.180 --> 00:30:07.740
trying to create a unique list.

00:30:07.740 --> 00:30:11.100
I think this might be for like showing some of the testimonials.

00:30:11.100 --> 00:30:16.100
It says, give me a list of all a bunch of testimonials and then randomly pick some out of it.

00:30:16.100 --> 00:30:18.960
And then it'll delete the one it randomly picked and then pick another.

00:30:18.960 --> 00:30:20.360
So it doesn't get duplication.

00:30:20.360 --> 00:30:21.960
There's, there's other things like that as well.

00:30:21.960 --> 00:30:22.740
Also in the search.

00:30:23.120 --> 00:30:28.520
And so I write Dell X bracket Y to get rid of the element or whatever it's called item.

00:30:28.520 --> 00:30:30.200
And they say, you know what?

00:30:30.200 --> 00:30:33.400
on a dictionary, you should just use X dot pop of Y.

00:30:33.400 --> 00:30:36.240
I think the Dell is kind of not obvious entirely what's going on.

00:30:36.240 --> 00:30:37.480
Sometimes it means free memory.

00:30:37.480 --> 00:30:39.500
Sometimes it means take the thing out of the list.

00:30:39.500 --> 00:30:40.020
Right?

00:30:40.120 --> 00:30:41.200
So they're like, okay, do this.

00:30:41.200 --> 00:30:47.200
And I got the square bracket in warning instead of the, parenthesis, the tuple version.

00:30:47.660 --> 00:30:53.000
And then also I had a list and I wanted to make a separate shallow copy of it.

00:30:53.000 --> 00:30:54.640
So I said, list of that thing.

00:30:54.640 --> 00:30:58.100
And I said, you can just do list dot copy or, you know, thing dot copy.

00:30:58.100 --> 00:31:01.700
And it'll create the same thing, but it's a little more discoverable what the intention is.

00:31:01.700 --> 00:31:03.220
Probably also more efficient.

00:31:03.220 --> 00:31:05.420
Probably do it all at once instead of loop over it.

00:31:05.420 --> 00:31:05.820
Who knows?

00:31:05.820 --> 00:31:09.180
Anyway, this is what I got running against our stuff like this.

00:31:09.320 --> 00:31:10.120
And you know what?

00:31:10.120 --> 00:31:10.860
I fixed it all.

00:31:10.860 --> 00:31:11.620
Cool.

00:31:11.620 --> 00:31:18.200
Except there's this one part where it's got a whole bunch of different tests to transform a string.

00:31:18.200 --> 00:31:22.380
And it's like line after line of dot replace, dot replace, dot replace, dot replace, dot replace.

00:31:22.380 --> 00:31:26.460
One of those lines is to replace tabs with spaces.

00:31:26.460 --> 00:31:31.780
Then eventually it finds all the spaces, turns them into single dashes and condenses them and whatnot.

00:31:31.780 --> 00:31:37.080
And it says, oh, you should change X dot replace backslash T.

00:31:37.080 --> 00:31:42.240
So tab with a space, replace that with X dot expand tabs one.

00:31:42.240 --> 00:31:44.060
I'm like, no.

00:31:44.060 --> 00:31:53.700
Maybe if it was just a single line where the only call was to replace the tabs, but there's like seven replaces.

00:31:53.700 --> 00:31:55.180
And they all make sense.

00:31:55.180 --> 00:31:58.680
Replace tabs, replace lowercase with that.

00:31:58.680 --> 00:32:00.280
Like all these other things.

00:32:00.280 --> 00:32:06.360
And if you just turn one of them into expand tabs, like why did, where did this come like into the sequence of replacements?

00:32:06.360 --> 00:32:07.900
Like, why would you do this one thing?

00:32:07.900 --> 00:32:08.420
Yeah.

00:32:08.420 --> 00:32:12.160
And so I just put a no QA on that one and, and fixed it up.

00:32:12.160 --> 00:32:16.040
But anyway, I found it to be pretty helpful in offering some nice recommendations.

00:32:16.040 --> 00:32:17.960
People can check it out.

00:32:17.960 --> 00:32:19.260
You can just run an entire directory.

00:32:19.260 --> 00:32:20.320
You don't have to run it on one file.

00:32:20.320 --> 00:32:23.560
Just say, you know, refurb dot slash go.

00:32:23.560 --> 00:32:24.420
Cool.

00:32:24.420 --> 00:32:24.980
Yeah.

00:32:24.980 --> 00:32:30.260
We should run like several of these and then just do them in a loop and see if it ever settles down.

00:32:30.260 --> 00:32:31.260
Exactly.

00:32:31.260 --> 00:32:34.820
If you just keep taking its advice, does it upset the other one?

00:32:34.820 --> 00:32:35.580
Yeah.

00:32:35.580 --> 00:32:40.300
Like if you py upgrade and then, then refurb and then black and just, and some others.

00:32:40.300 --> 00:32:40.920
Yeah.

00:32:40.920 --> 00:32:41.720
Auto pepe.

00:32:41.720 --> 00:32:42.660
Yeah.

00:32:43.660 --> 00:32:46.780
The goal of this one is to modernize Python code bases.

00:32:46.780 --> 00:32:50.580
If we had Python two code, I suspect it would go bonkers, but we don't.

00:32:50.580 --> 00:32:51.120
So it's okay.

00:32:51.120 --> 00:32:54.840
But one of the cool thing you, you mentioned you weren't going to do the expand tabs, but

00:32:54.840 --> 00:32:57.080
I didn't know about the expand tabs.

00:32:57.440 --> 00:33:03.740
So the tools like this also just like teach you stuff that you may not have known about

00:33:03.740 --> 00:33:04.040
the language.

00:33:04.040 --> 00:33:04.460
Yeah.

00:33:04.460 --> 00:33:06.580
Like that read text versus a context manager and all sorts of stuff.

00:33:06.580 --> 00:33:06.820
Yeah.

00:33:06.820 --> 00:33:07.220
Yeah.

00:33:07.220 --> 00:33:07.620
Yeah.

00:33:07.620 --> 00:33:09.740
So the expand tabs, not where was it?

00:33:09.740 --> 00:33:10.160
It was over here.

00:33:10.160 --> 00:33:14.440
The expand tabs of one, that means replace the tab with one space.

00:33:14.440 --> 00:33:17.640
So if you wanted like four spaces for every tab, you would just say expand tabs four.

00:33:17.960 --> 00:33:19.480
Which is probably correct, right?

00:33:19.480 --> 00:33:20.260
Yeah, of course.

00:33:20.260 --> 00:33:22.300
Of course it is.

00:33:22.300 --> 00:33:23.040
Of course it is.

00:33:23.040 --> 00:33:24.660
All right.

00:33:24.660 --> 00:33:25.920
Well, that's it for all of our items.

00:33:25.920 --> 00:33:27.120
You got anything else you want to throw out there?

00:33:27.120 --> 00:33:29.060
I don't.

00:33:29.060 --> 00:33:29.960
How about you?

00:33:29.960 --> 00:33:32.040
I do actually.

00:33:32.040 --> 00:33:32.460
All right.

00:33:32.460 --> 00:33:33.560
So let's, let's see.

00:33:33.560 --> 00:33:34.140
I got a few things.

00:33:34.140 --> 00:33:34.840
I'll go through them quick.

00:33:34.840 --> 00:33:38.900
So another sequence of things that I think is pretty interesting.

00:33:38.900 --> 00:33:42.460
This is not really the main thing, but it's kind of starting the motivation.

00:33:43.240 --> 00:33:49.280
So we have over on all of our sites on Python bytes, on Talk Python and Talk Python training,

00:33:49.280 --> 00:33:51.920
we have the ability to do search.

00:33:51.920 --> 00:33:56.220
So for example, over on Talk Python training, I can say in Grok API postman.

00:33:56.220 --> 00:33:59.960
And the results you got were just like previously were like this ugly list that you'd have to

00:33:59.960 --> 00:34:00.760
kind of make sense of.

00:34:00.760 --> 00:34:05.300
It was, it was really not something I was too proud of, but I'm like, I'm not inspired to

00:34:05.300 --> 00:34:09.000
figure out a different UI, but I got inspired last week and said, okay, I'm going to come up with

00:34:09.000 --> 00:34:13.080
this kind of like hierarchical view showing like, okay, if I search for say,

00:34:13.180 --> 00:34:19.400
in Grok API postman, I want to see all the stuff that matches that out of the 240 hours

00:34:19.400 --> 00:34:21.500
of spoken word, basically, right.

00:34:21.500 --> 00:34:24.760
On the site and all the descriptions and titles and so on.

00:34:24.760 --> 00:34:30.340
And so like, for example, this Twilio course I talked about used all those things and actually

00:34:30.340 --> 00:34:35.280
has one lecture where exactly it talks about all three of those things.

00:34:35.280 --> 00:34:40.300
And then others where they're in there, but like one, one video talks about in Grok, then

00:34:40.300 --> 00:34:44.120
another one talks about an API or, you know, some, it's not really focused.

00:34:44.120 --> 00:34:44.420
Right.

00:34:44.420 --> 00:34:48.640
And here just in this course, like it doesn't even exist in a single chapter, but across

00:34:48.640 --> 00:34:51.880
a hundred days of web and Python, like all those words are said.

00:34:51.880 --> 00:34:52.220
Right.

00:34:52.220 --> 00:34:58.120
So I came up with this search engine and well, the search engine existed, but it wasn't running

00:34:58.120 --> 00:35:01.140
in a, it wasn't basically hosted in a way that I was real happy with.

00:35:01.140 --> 00:35:05.400
So what I did is I took some of our advice from 2017.

00:35:05.400 --> 00:35:06.820
I said, you know what?

00:35:06.820 --> 00:35:13.420
I'm going to create, I'm going to create a system B service that just runs as part of

00:35:13.420 --> 00:35:14.080
Linux.

00:35:14.080 --> 00:35:18.060
When I turn it on, that is going to do all the indexing and a lot of the pre-processing.

00:35:18.060 --> 00:35:19.460
So that page can be super fast.

00:35:19.460 --> 00:35:23.160
So for example, like the response time for this page is effectively instant.

00:35:23.160 --> 00:35:25.160
It's like 30, 40 milliseconds.

00:35:25.160 --> 00:35:25.480
Right.

00:35:25.480 --> 00:35:27.300
Even though it's, it's doing tons of searching.

00:35:27.300 --> 00:35:34.980
So I'm going to run this Python script series of scripts in the little app as a system D service,

00:35:34.980 --> 00:35:36.140
which is excellent.

00:35:36.140 --> 00:35:37.680
And so we talked about how you can do that.

00:35:37.680 --> 00:35:42.960
And, you know, if you look, here's a, an example, basically you just create a system D dot

00:35:42.960 --> 00:35:43.700
service file.

00:35:43.940 --> 00:35:49.440
And you say like Python space, your file with the arguments and you can set up and I'll

00:35:49.440 --> 00:35:53.840
just auto start and be managed by, you know, system control, which is awesome.

00:35:53.840 --> 00:35:56.160
So that's all neat.

00:35:56.160 --> 00:36:00.100
The other thing I want to give, this is the main thing I really want to give some advice

00:36:00.100 --> 00:36:06.380
about though, is those, these, these daemons, what they look like is while true, chill out

00:36:06.380 --> 00:36:12.500
for a while, do your thing, wait for an event, do your thing, look for a file, do your thing,

00:36:12.500 --> 00:36:14.060
then look for it for some more, right?

00:36:14.060 --> 00:36:18.640
You're just going over and over in this loop, like running, but often it's not busy, right?

00:36:18.640 --> 00:36:20.940
It's waiting for something in the search thing.

00:36:20.940 --> 00:36:22.640
It's like waiting for an hour or something.

00:36:22.640 --> 00:36:27.540
Then it'll rebuild the search, but it could just as well be waiting for a file to appear

00:36:27.540 --> 00:36:31.400
in some kind of upload folder and then like start processing that.

00:36:31.400 --> 00:36:32.040
I don't know.

00:36:32.040 --> 00:36:32.800
Right.

00:36:32.800 --> 00:36:38.740
So it ha they almost always have this pattern of like while true, either wait for an event

00:36:38.740 --> 00:36:42.440
and then do it or chill for a while and then do the thing.

00:36:42.440 --> 00:36:50.040
So my recommendation, my thought here is if you combine this with multi-processing, you

00:36:50.040 --> 00:36:55.320
can often get much, much lower overhead on your server, right?

00:36:55.320 --> 00:36:57.080
So check this out.

00:36:57.080 --> 00:37:01.820
So here's a, an example of the search thing on Talk Python search out of Glances.

00:37:01.820 --> 00:37:06.340
Notice it's using 78 megabytes of RAM.

00:37:06.500 --> 00:37:07.920
This is in the beginning of show notes, of course.

00:37:07.920 --> 00:37:10.100
This is it just running there in the background.

00:37:10.100 --> 00:37:16.460
Before I started using multi-processing, it was using like 300 megs of RAM constantly on

00:37:16.460 --> 00:37:22.520
the server because it would wait for an hour and then it would load up the entire 240 hours

00:37:22.520 --> 00:37:28.020
of text and stuff and process it and do database calls and then generate like a search result,

00:37:28.100 --> 00:37:33.160
a search set of keyword maps and then it would, you know, would refresh those again.

00:37:33.160 --> 00:37:36.020
But normally it's just resting.

00:37:36.020 --> 00:37:37.640
It puts that stuff back in the database.

00:37:37.640 --> 00:37:44.860
But if you like let it actually do the work, it will basically not, not unload those modules

00:37:44.860 --> 00:37:47.280
and unload all that other stuff that happened in there.

00:37:47.380 --> 00:37:52.240
So if you take the function that says just do the one thing in the loop and you just call

00:37:52.240 --> 00:37:56.620
that with multi-processing, it goes from 350 megs to 70 megs.

00:37:56.620 --> 00:37:57.600
No other work.

00:37:57.600 --> 00:38:01.260
Because it, that little thing fires up, it does all the work and then it shuts back down and

00:38:01.260 --> 00:38:04.160
it doesn't get like all that extra stuff loaded into your process.

00:38:04.160 --> 00:38:04.720
Okay.

00:38:04.720 --> 00:38:05.880
A little cool, right?

00:38:05.880 --> 00:38:07.000
It is cool.

00:38:07.000 --> 00:38:12.960
You could, I mean, for special cases like ours, I mean, for yours, you could just kick it

00:38:12.960 --> 00:38:13.780
off yourself, right?

00:38:13.780 --> 00:38:17.800
Or as avid, be part of your published thing when you publish new show notes.

00:38:17.800 --> 00:38:20.100
Yeah, exactly.

00:38:20.100 --> 00:38:23.720
I mean, I could, I could base it on some of that.

00:38:23.720 --> 00:38:29.520
Like, yeah, it could, it gets complicated because it's hard to tell when that happens.

00:38:29.520 --> 00:38:30.680
Yeah.

00:38:30.680 --> 00:38:34.260
There's, there's like a, as you can see, like in this example, there's like eight worker

00:38:34.260 --> 00:38:35.560
processes, right?

00:38:35.560 --> 00:38:39.100
So which one should be in charge of knowing that?

00:38:39.100 --> 00:38:39.480
I don't know.

00:38:39.540 --> 00:38:43.460
It's, so it's, it's easy to just have that thing running and just like, you know, the

00:38:43.460 --> 00:38:48.220
search will be up to date and it's going, but please don't overwhelm the server by loading

00:38:48.220 --> 00:38:50.360
the entire thing and hanging on to it forever.

00:38:50.360 --> 00:38:51.060
Yeah, exactly.

00:38:51.060 --> 00:38:52.000
Yeah.

00:38:52.000 --> 00:38:54.800
So anyway, I thought that was a fun story to share.

00:38:54.800 --> 00:38:56.720
Let's do this one next.

00:38:56.720 --> 00:38:58.940
We talked about JetBrains Fleet.

00:38:58.940 --> 00:39:01.080
Think PyCharm.

00:39:01.080 --> 00:39:08.360
PyCharm's like little cousin that is very much like VS Code, I guess, but as like PyCharm

00:39:08.360 --> 00:39:09.460
heritage.

00:39:09.460 --> 00:39:15.100
So this thing is now out of private beta is now into public beta.

00:39:15.100 --> 00:39:17.960
So it has like Google Docs type collaboration.

00:39:17.960 --> 00:39:25.420
It has, but it has like PyCharm source code refactoring and deep understanding that seems

00:39:25.420 --> 00:39:26.100
pretty excellent.

00:39:26.100 --> 00:39:28.620
So people can check that out.

00:39:28.620 --> 00:39:29.720
It looks, looks pretty neat.

00:39:29.720 --> 00:39:32.640
I've done a little bit of playing with it, but not too much yet.

00:39:32.640 --> 00:39:37.280
But if you're a VS Code type of person, like this might speak to you more than PyCharm.

00:39:37.280 --> 00:39:38.020
So that's out.

00:39:38.020 --> 00:39:44.520
Speaking of PyCharm, I'm going to be on a webcast with Paul Everett on Thursday.

00:39:44.520 --> 00:39:48.620
We're talking about Django and PyCharm tips reloaded.

00:39:48.700 --> 00:39:53.160
So just kind of a bunch of cool things you can do to, if you're working in a Django project

00:39:53.160 --> 00:39:56.160
in PyCharm, you want to be awesome and quick and efficient.

00:39:56.160 --> 00:39:57.080
Okay.

00:39:57.080 --> 00:39:57.760
Last one.

00:39:57.760 --> 00:39:58.660
How about this?

00:39:58.660 --> 00:40:01.480
This, this Mark, go ahead.

00:40:01.800 --> 00:40:03.640
This blows me away and it's interesting.

00:40:03.640 --> 00:40:05.740
So this is interesting.

00:40:05.740 --> 00:40:09.540
So we all have got to be familiar with the GDPR.

00:40:09.540 --> 00:40:16.580
I did weeks worth of work reworking the various websites to be officially compliant with GDPR.

00:40:16.580 --> 00:40:21.140
You know, like we weren't doing any creepy stuff to like, oh, now we've got to start, stop

00:40:21.140 --> 00:40:22.900
our tracking or anything like that.

00:40:22.900 --> 00:40:27.000
But like, there's certain things about you need to record the opt-in explicitly and be able

00:40:27.000 --> 00:40:28.860
to associate a record like that kind of stuff.

00:40:28.860 --> 00:40:29.000
Right.

00:40:29.620 --> 00:40:34.960
So some of us did a bunch of work to make our code GDPR compliant.

00:40:34.960 --> 00:40:37.160
Others, not so much.

00:40:37.160 --> 00:40:43.600
But the news here is that Denmark has ruled that Google Analytics is illegal.

00:40:43.600 --> 00:40:45.460
I mean, like, okay.

00:40:45.460 --> 00:40:54.320
And illegal in the sense that the Google Analytics violates the GDPR and basically can't be used.

00:40:55.320 --> 00:41:00.560
I believe France and two other countries whose name I'm forgetting.

00:41:00.560 --> 00:41:03.540
I've also decided that as well.

00:41:03.540 --> 00:41:11.220
And yeah, more or less, they, a significant number of European countries are deciding that

00:41:11.220 --> 00:41:17.320
Google Analytics just can't be used if you are going to be following the GDPR, which I think

00:41:17.320 --> 00:41:22.540
most companies in the West, at least, need to follow.

00:41:22.540 --> 00:41:23.360
Yeah.

00:41:23.360 --> 00:41:25.000
So I'm glad.

00:41:25.000 --> 00:41:30.160
I mean, my early days of web stuff, I was using Google Analytics.

00:41:30.160 --> 00:41:32.160
Of course, a lot of people do.

00:41:32.160 --> 00:41:32.880
Yeah.

00:41:32.880 --> 00:41:34.380
And it's free.

00:41:34.380 --> 00:41:36.880
They give you all this information free.

00:41:36.880 --> 00:41:37.820
Why not?

00:41:37.820 --> 00:41:38.480
Why are they giving?

00:41:38.480 --> 00:41:39.700
Oh, it's not.

00:41:39.700 --> 00:41:40.160
Wait a minute.

00:41:40.160 --> 00:41:41.200
Wait a second.

00:41:41.580 --> 00:41:46.300
They're using you and your website to help collect data on everybody that uses your website.

00:41:46.300 --> 00:41:46.620
Yeah.

00:41:46.620 --> 00:41:47.960
It seems like such a good trade-off.

00:41:47.960 --> 00:41:55.260
But yeah, I mean, you're basically giving like every single action on your website, giving

00:41:55.260 --> 00:42:00.180
that information about your users, every one of their actions over to Google, which seems

00:42:00.180 --> 00:42:05.320
like a little, I could see why that would be looked down upon from a GDPR perspective, no

00:42:05.320 --> 00:42:05.620
doubt.

00:42:05.620 --> 00:42:12.820
Just by the way, also on that, if you look over on Python Bytes, the pay, let's see, does

00:42:12.820 --> 00:42:13.320
it say anything?

00:42:13.320 --> 00:42:19.200
How many, how many blockers have we got or how many creepy things do we have to worry about

00:42:19.200 --> 00:42:19.640
over here?

00:42:19.640 --> 00:42:20.220
Zero.

00:42:20.220 --> 00:42:22.220
Like we don't use Google Analytics.

00:42:22.220 --> 00:42:25.320
We don't use, yeah, that's just global stats.

00:42:25.320 --> 00:42:31.120
But yeah, we don't use Google Analytics or any other form of client-side analytics whatsoever.

00:42:31.120 --> 00:42:33.720
So I'm pretty happy about that actually.

00:42:33.720 --> 00:42:36.940
But check out the video by Steve Gibson.

00:42:36.940 --> 00:42:41.400
It's an excerpt of a different podcast, but I think it's worth covering.

00:42:41.400 --> 00:42:42.140
It's pretty interesting.

00:42:42.140 --> 00:42:42.720
Yeah.

00:42:42.720 --> 00:42:44.880
It's something to watch at least.

00:42:44.880 --> 00:42:45.580
Yeah.

00:42:45.580 --> 00:42:46.300
Yeah.

00:42:46.300 --> 00:42:49.860
Ikivu points out in the audience, how can you enforce something like that?

00:42:49.860 --> 00:42:51.920
That is Google Analytics being not allowed.

00:42:51.920 --> 00:42:53.940
It's embedded in so many sites everywhere.

00:42:53.940 --> 00:42:55.880
Sometimes you don't even manage it.

00:42:55.880 --> 00:42:58.440
You just enter an analytics ID.

00:42:58.440 --> 00:42:58.720
Yeah.

00:42:59.680 --> 00:43:02.520
It's honestly a serious problem.

00:43:02.520 --> 00:43:08.660
Like, for example, on our Python Bytes website, if you go to one of the newer episodes, they

00:43:08.660 --> 00:43:11.440
all have a nice little picture.

00:43:11.440 --> 00:43:14.380
That picture is from the YouTube thumbnail.

00:43:14.780 --> 00:43:17.220
Like, it literally pulls it straight from YouTube.

00:43:17.220 --> 00:43:24.940
The first thing I tried to do, Brian, was I said, well, here's the image that YouTube uses for the poster on the video.

00:43:24.940 --> 00:43:31.220
So I'll just put a little image where the source is youtube.com slash video poster, whatever the heck the URL is.

00:43:32.000 --> 00:43:36.020
Even for that, Google started putting tracking cookies on all of our visitors.

00:43:36.020 --> 00:43:37.740
Like, come on, Google.

00:43:37.740 --> 00:43:38.560
It's just an image.

00:43:38.560 --> 00:43:39.020
No.

00:43:39.020 --> 00:43:39.980
Tracking cookies.

00:43:39.980 --> 00:43:40.580
Yeah.

00:43:40.580 --> 00:43:41.100
Yeah.

00:43:41.100 --> 00:43:42.700
Or cookies, right?

00:43:42.700 --> 00:43:51.800
So what I had to end up doing is the website on the server side looks at the URL, downloads the images, puts it in MongoDB.

00:43:51.980 --> 00:43:55.260
And when a visitor comes, we serve it directly out of MongoDB with no cookies.

00:43:55.260 --> 00:44:00.360
Like, it is not trivial to avoid getting that kind of stuff in there.

00:44:00.360 --> 00:44:05.300
Because even when you try not to, it shows up a lot of times, like Icavu mentioned.

00:44:05.300 --> 00:44:05.920
Yeah.

00:44:05.920 --> 00:44:09.320
The way it gets enforced, somebody says, here's a big website.

00:44:09.320 --> 00:44:12.400
They're violating the GDPR.

00:44:12.400 --> 00:44:13.980
We're going to recommend.

00:44:13.980 --> 00:44:16.480
I'm going to report them, basically, is what happens, I think.

00:44:16.860 --> 00:44:17.140
Yeah.

00:44:17.140 --> 00:44:26.800
But I think for small fish, like me or something, it's just, if a country says, don't do that, maybe I won't.

00:44:26.800 --> 00:44:28.540
Because they might have good reasons.

00:44:28.540 --> 00:44:29.440
Yeah.

00:44:29.440 --> 00:44:31.700
And if you're a business, you've got to worry a lot more.

00:44:31.700 --> 00:44:35.100
I don't think any individual will ever get in trouble for that.

00:44:35.100 --> 00:44:41.360
But it's also, I mean, think about how much you're exposing everybody's information.

00:44:41.360 --> 00:44:44.980
And you can't know before you go to a website whether that's going to happen.

00:44:44.980 --> 00:44:46.700
It's already happened once you get there.

00:44:46.700 --> 00:44:52.500
So I guess, see our previous conversation about ad blockers, NextDNS, do we hate creators?

00:44:52.500 --> 00:44:53.000
No.

00:44:53.000 --> 00:44:54.300
Do we hate this kind of stuff?

00:44:54.300 --> 00:44:54.660
Yes.

00:44:54.660 --> 00:44:55.260
Yeah.

00:44:55.260 --> 00:44:55.800
Anyway.

00:44:55.800 --> 00:44:57.840
Also, information is interesting.

00:44:57.840 --> 00:45:02.840
So, but just pay attention to what you have, because you don't need Google Analytics to just

00:45:02.840 --> 00:45:05.160
find out which pages are viewed most.

00:45:05.160 --> 00:45:05.880
Absolutely.

00:45:05.880 --> 00:45:06.220
Things like that.

00:45:06.220 --> 00:45:07.200
You can use other ways.

00:45:07.200 --> 00:45:08.060
Yep.

00:45:08.060 --> 00:45:09.400
All right.

00:45:09.400 --> 00:45:11.860
Well, that's a bunch of extras, but there they are.

00:45:11.860 --> 00:45:13.780
That's so serious, though.

00:45:13.780 --> 00:45:14.840
Do we have something funny?

00:45:14.840 --> 00:45:15.640
We do.

00:45:15.640 --> 00:45:16.140
Okay.

00:45:16.460 --> 00:45:20.120
Something, I got some, this is very much, I picked this one for you, Brian.

00:45:20.120 --> 00:45:20.900
Okay.

00:45:20.900 --> 00:45:22.360
So this has to do with testing.

00:45:22.360 --> 00:45:23.800
Tell me what's in this picture here.

00:45:23.800 --> 00:45:25.000
Describe for our listeners.

00:45:25.000 --> 00:45:26.280
I love this picture.

00:45:26.280 --> 00:45:29.080
This is great.

00:45:29.080 --> 00:45:32.180
So it says, all unit test passing.

00:45:32.180 --> 00:45:34.940
And it is a completely shattered sink.

00:45:35.080 --> 00:45:40.380
The only thing left of the sink is the faucet is still attached to some porcelain.

00:45:40.740 --> 00:45:41.400
You can turn it on.

00:45:41.400 --> 00:45:42.020
You can turn it on.

00:45:42.020 --> 00:45:43.500
And it goes down the drain.

00:45:43.500 --> 00:45:46.840
Actually, so you've already, you've even got integration tests passing.

00:45:46.840 --> 00:45:47.260
Yeah, you do.

00:45:47.260 --> 00:45:48.300
This is pretty, yeah.

00:45:48.300 --> 00:45:50.720
This is pretty, not 100% coverage, but.

00:45:50.720 --> 00:45:51.880
Yeah.

00:45:51.880 --> 00:45:53.060
Right.

00:45:53.060 --> 00:45:54.940
Not 100% coverage of the sink.

00:45:54.940 --> 00:45:56.140
Yeah.

00:45:56.140 --> 00:45:58.240
There's this sink and it's completely smashed.

00:45:58.240 --> 00:46:01.780
There's just like, just a little tiny chunk fragment of it left.

00:46:01.840 --> 00:46:04.780
But it's got the drain and the faucet is still pouring into it.

00:46:04.780 --> 00:46:05.540
Unit test pass.

00:46:05.540 --> 00:46:05.980
I love it.

00:46:05.980 --> 00:46:06.660
Yeah.

00:46:06.660 --> 00:46:09.600
You might even cut yourself if you tried to wash your hands in this.

00:46:09.600 --> 00:46:11.940
But, but funny.

00:46:11.940 --> 00:46:12.360
You might.

00:46:12.360 --> 00:46:13.180
You might.

00:46:13.180 --> 00:46:14.800
Well.

00:46:14.800 --> 00:46:15.720
That's good.

00:46:15.720 --> 00:46:16.580
Fun as always.

00:46:16.580 --> 00:46:17.560
Thanks for being here.

00:46:17.560 --> 00:46:18.240
Thank you.

00:46:18.240 --> 00:46:18.900
Yeah.

00:46:18.900 --> 00:46:19.580
See you later.

00:46:19.580 --> 00:46:20.980
Thank you everyone for listening.

00:46:20.980 --> 00:46:21.620
Bye.

