WEBVTT

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

00:00:04.920 --> 00:00:09.360
It's episode 91, recorded August 8th, 2018. I'm Michael Kennedy.

00:00:09.360 --> 00:00:10.340
And I'm Brian Okken.

00:00:10.340 --> 00:00:11.180
Hey, Brian. How are you doing?

00:00:11.180 --> 00:00:12.040
I'm doing great.

00:00:12.040 --> 00:00:16.680
Awesome. Well, as always, the Python news cycle has not let us down, has it?

00:00:16.680 --> 00:00:19.360
No, it's keeping up. It's good.

00:00:19.360 --> 00:00:21.080
It's definitely. We've got a lot of good stuff to cover.

00:00:21.080 --> 00:00:24.740
Before we do, though, another thing not letting us down is Datadog.

00:00:24.740 --> 00:00:27.060
They're definitely helping us prop up.

00:00:27.060 --> 00:00:28.880
So thank you, Datadog, for sponsoring this episode.

00:00:29.020 --> 00:00:31.300
Check them out at pythonbytes.fm.datadog.

00:00:31.300 --> 00:00:33.920
They actually have some cool new announcements, which I'll get to later.

00:00:33.920 --> 00:00:36.780
But let's talk about what makes Python cool, huh?

00:00:36.780 --> 00:00:38.580
There's a lot of stuff that makes Python cool.

00:00:38.580 --> 00:00:41.780
But there was an article that came up.

00:00:41.780 --> 00:00:43.300
I think it's on Medium.

00:00:43.300 --> 00:00:45.100
HackerNoon. That's right.

00:00:45.100 --> 00:00:47.560
Sorry, HackerNoon, that I thought you were Medium for a second.

00:00:47.560 --> 00:00:49.260
By Shankar Jha.

00:00:49.260 --> 00:00:52.460
And I probably mispronounced his last name. Apologies.

00:00:52.460 --> 00:00:55.520
But an article called What Makes Python Cool.

00:00:55.520 --> 00:00:58.980
And my first reaction is like, oh, yet another rah-rah.

00:00:58.980 --> 00:00:59.860
Python is awesome.

00:00:59.860 --> 00:01:11.660
But it is actually kind of a neat article because it talks about some of the things that a lot of people that are just starting out or starting to learn Python or they have to might not stumble around.

00:01:11.940 --> 00:01:13.860
They might not run into for a while.

00:01:13.860 --> 00:01:15.660
And they're good things to note.

00:01:15.660 --> 00:01:19.720
So he starts off with the Zen of Python with import this.

00:01:19.720 --> 00:01:22.820
And it's a good thing for people to look at.

00:01:22.820 --> 00:01:29.340
And then, of course, if you're looking at cool imports, import anti-gravity that redirects you to XKCD is cool.

00:01:29.880 --> 00:01:35.440
Yeah, if people have never typed import anti-gravity in their REPL in Python, they should definitely do that.

00:01:35.440 --> 00:01:39.160
And those two things actually make it – they're not just jokes.

00:01:39.160 --> 00:01:46.620
It kind of indoctrinates you into the fact that the Python community doesn't take itself too awfully seriously.

00:01:46.620 --> 00:01:50.140
It's all serious work and we do a lot of important things.

00:01:50.140 --> 00:01:52.600
But it's a good, fun thing to have there.

00:01:52.600 --> 00:01:54.340
So I hope they never take those out.

00:01:54.340 --> 00:01:55.140
Yeah, I agree.

00:01:55.140 --> 00:02:02.080
And then things that he starts off right off the bat after that with how to swap two variables in one line.

00:02:02.080 --> 00:02:07.100
Like A, B equals B, A.

00:02:07.100 --> 00:02:08.940
We're just used to that now.

00:02:08.940 --> 00:02:16.540
But when you first see this – or a lot of people don't think they can do that because you can't do that in C, I don't think.

00:02:16.540 --> 00:02:18.320
You didn't used to be able to at least.

00:02:18.320 --> 00:02:19.000
Nope, I don't think so.

00:02:19.000 --> 00:02:20.800
And it's a fun extra thing.

00:02:20.800 --> 00:02:24.260
How fast you can spin up a web server just with one line.

00:02:24.260 --> 00:02:32.140
A reminder to take a look at the collections and iter tools modules or packages because there are a whole bunch of good stuff in there.

00:02:32.140 --> 00:02:38.260
Enumerate with the enumerate keyword is – or built in, whatever that is.

00:02:38.260 --> 00:02:45.460
It's a really cool thing and it keeps people from keeping track of their own indices when they're going through lists.

00:02:45.460 --> 00:02:51.740
Do you know what I learned from Bob Beldervos from PyBytes with an I, not a Y, not Python bytes, about enumerate?

00:02:51.740 --> 00:02:56.300
Is it takes an extra parameter that will let the index start at one or anything you specify.

00:02:56.300 --> 00:03:00.620
Because I've always had like it go at zero, then I'll have like index plus one all over the place.

00:03:00.620 --> 00:03:02.300
Well, you can just say start at one, two, three.

00:03:02.300 --> 00:03:03.280
That's a parameter in there.

00:03:03.280 --> 00:03:03.660
It's nice.

00:03:03.660 --> 00:03:08.620
Yeah, and that's a brilliant thing because, yeah, I've seen that a lot of people adding one.

00:03:08.620 --> 00:03:10.960
Just start at one and then it's in the right order.

00:03:11.380 --> 00:03:20.800
Easily reverse a list, doing zip, a couple zip tricks, how cool comprehensions and dictionaries are, and pretty print with pprint.

00:03:20.800 --> 00:03:22.060
Anyway, it's a good article.

00:03:22.060 --> 00:03:22.800
Yeah, absolutely.

00:03:22.800 --> 00:03:24.960
I really – I think it covers a lot of nice stuff.

00:03:24.960 --> 00:03:29.180
And if you're kind of new to Python, there are some cool things in here that you'll be like,

00:03:29.180 --> 00:03:35.820
oh, I didn't know when I was working in the REPL that if I forgot to assign some computation to a variable,

00:03:35.820 --> 00:03:39.440
I can still access it one time quickly as an underscore.

00:03:39.440 --> 00:03:40.660
So that's pretty cool.

00:03:40.800 --> 00:03:42.360
Yeah, I actually forget that all the time.

00:03:42.360 --> 00:03:47.500
So I'm glad that people keep putting that down because I forget about it and it saves time.

00:03:47.500 --> 00:03:49.680
The many uses and meanings of underscore.

00:03:49.680 --> 00:03:52.740
Yeah, and we're not even in Perl.

00:03:52.740 --> 00:03:53.500
Yeah, exactly.

00:03:53.500 --> 00:03:57.480
So if I were a Django person, I'm not.

00:03:57.480 --> 00:04:00.700
My sites are based on Pyramid and Flask and things like that.

00:04:01.000 --> 00:04:07.360
But if I were a Django person, I'd be doing a bit of a backflip right now because there's a brand new major Django release.

00:04:07.360 --> 00:04:12.180
And this is the first major release after Django kicked Legacy Python out the door.

00:04:12.180 --> 00:04:13.560
So Django 2.1 is out.

00:04:13.560 --> 00:04:14.180
Pretty cool, huh?

00:04:14.420 --> 00:04:14.680
Yeah.

00:04:14.680 --> 00:04:16.400
What do we got in 2.1?

00:04:16.400 --> 00:04:17.900
Well, there's actually a ton of features.

00:04:17.900 --> 00:04:22.420
I think the one that the team highlights the most is this thing called model view permissions.

00:04:22.800 --> 00:04:24.980
So Django comes with its ORM, right?

00:04:24.980 --> 00:04:26.020
Its own ORM.

00:04:26.020 --> 00:04:29.160
And in there, you have models that map to the database.

00:04:29.160 --> 00:04:34.340
And now you can set it up so you have view-only permissions on models, which is pretty cool.

00:04:35.220 --> 00:04:39.300
And they said Django 2 has reached the end of mainstream support.

00:04:39.300 --> 00:04:47.360
They just released 2.0.8, which is the final version you're ever going to see except for possible security fixes until April of 2019.

00:04:47.360 --> 00:04:49.640
But after that, there's going to be no more Django 2.0.

00:04:49.640 --> 00:04:51.600
So be sure to look about upgrading.

00:04:51.600 --> 00:04:54.460
And then in terms of features, we have the model view feature.

00:04:54.460 --> 00:04:59.400
We also have the ability to customize how deletes happen.

00:04:59.400 --> 00:05:01.280
So there's like a delete query set option.

00:05:01.280 --> 00:05:04.300
So you can delete select objects and customize that.

00:05:04.300 --> 00:05:06.380
There's a way to override the default admin site.

00:05:06.380 --> 00:05:08.080
There's tons of ORM features.

00:05:08.080 --> 00:05:09.960
I highlighted one, but there's actually a whole bunch.

00:05:09.960 --> 00:05:12.140
Caching is pretty cool.

00:05:12.140 --> 00:05:15.240
So caching used to kind of like store items.

00:05:15.240 --> 00:05:17.940
And when it got full, it would just randomly start throwing stuff out.

00:05:17.940 --> 00:05:21.720
And now it uses LRU, last recently used to call.

00:05:21.720 --> 00:05:24.740
So like a better sort of the hot stuff stays in the cache, which is good.

00:05:24.740 --> 00:05:29.180
Migrations can now be run from PYC, so compiled files.

00:05:29.180 --> 00:05:34.200
So in frozen environments that are just have the binary bytecode, you can still run migrations and tons more.

00:05:34.200 --> 00:05:35.780
Wow, that's actually pretty cool.

00:05:35.780 --> 00:05:37.000
Yeah, there's a lot of stuff in there.

00:05:37.000 --> 00:05:41.060
Like there's pages and pages of changes from Django 2, which is pretty awesome.

00:05:41.060 --> 00:05:49.520
Yeah, actually, if I was going to go look at Django, which is on my to-do list, the ability to overwrite the default admin site, that sounds kind of neat.

00:05:49.520 --> 00:05:54.080
Because I'm not really a fan of the look of the default admin site.

00:05:54.080 --> 00:05:55.420
Yeah, it's pretty cool.

00:05:55.420 --> 00:05:55.700
Great.

00:05:55.700 --> 00:05:58.800
So you've got one that's a little playful, right?

00:05:58.800 --> 00:05:59.240
Yeah.

00:05:59.240 --> 00:06:01.460
So this is actually pretty awesome.

00:06:02.640 --> 00:06:04.440
It's actually a GitHub repo.

00:06:04.440 --> 00:06:07.300
And I'm going to look this person up.

00:06:07.300 --> 00:06:12.360
It's Annalena Popkis, which actually I might have actually got that last name right.

00:06:12.360 --> 00:06:12.840
Who knows?

00:06:12.840 --> 00:06:18.620
But she's a computer science graduate student or computer science graduate.

00:06:19.200 --> 00:06:22.540
She's working as an intern right now, according to her blog.

00:06:22.540 --> 00:06:25.560
But it's like the whole 100 days of code thing.

00:06:25.560 --> 00:06:31.520
But she's doing it all in the open and all in Harry Potter themes.

00:06:31.520 --> 00:06:33.380
And it's really fun.

00:06:33.380 --> 00:06:37.340
And so far, it's up to day 18.

00:06:37.860 --> 00:06:39.500
So she's still working on it.

00:06:39.500 --> 00:06:42.240
And hopefully, we'll continue it all with it.

00:06:42.240 --> 00:06:44.520
But this is just some really fun stuff.

00:06:44.520 --> 00:06:50.580
And I like the idea of using a theme for going through a 100 days of code system.

00:06:50.580 --> 00:06:51.780
So it's kind of fun.

00:06:51.780 --> 00:06:52.260
Yeah.

00:06:52.260 --> 00:06:57.380
So to give people an idea of what you're describing and what she's doing is like, for example, on

00:06:57.380 --> 00:07:00.320
days 16, 17, 18, she worked with data classes.

00:07:00.320 --> 00:07:02.720
Data classes are a cool 3-7 thing that are awesome.

00:07:02.720 --> 00:07:05.320
And she's modeling a house, right?

00:07:05.320 --> 00:07:11.040
When the young wizard students go off to the wizard school, they go into like Gryffindor

00:07:11.040 --> 00:07:12.940
and Slytherin and the different houses.

00:07:12.940 --> 00:07:16.460
And so like her whole example of exploring data classes is about that.

00:07:16.460 --> 00:07:21.640
What also I think is actually going to pay off pretty big time for her is every one of these,

00:07:21.640 --> 00:07:25.160
she's not just writing the code and putting it in a separate section in GitHub.

00:07:25.160 --> 00:07:29.280
But she's also doing like a full-on explanatory blog post.

00:07:29.280 --> 00:07:33.200
Like this one is probably six pages of writing about it.

00:07:33.200 --> 00:07:35.840
And that's got to help understand it really well and make it stick.

00:07:35.840 --> 00:07:36.380
Yeah.

00:07:36.380 --> 00:07:41.940
And then it's also, you know, 100 days of writing, you know, practice writing about text stuff.

00:07:41.940 --> 00:07:43.960
So yeah, it'll definitely help.

00:07:43.960 --> 00:07:44.900
It's a good idea.

00:07:44.900 --> 00:07:45.340
Yeah.

00:07:45.340 --> 00:07:45.740
I love it.

00:07:45.740 --> 00:07:46.720
I'm glad you brought that one in.

00:07:46.720 --> 00:07:47.600
I saw that come up.

00:07:47.600 --> 00:07:49.400
I'm like, wow, that's pretty clever.

00:07:49.400 --> 00:07:50.260
Well done, Anna.

00:07:50.260 --> 00:07:50.700
Nice.

00:07:50.700 --> 00:07:51.680
All right.

00:07:51.780 --> 00:07:55.960
Before we move on to the next one, let me tell you about a new feature from Datadog.

00:07:55.960 --> 00:07:59.360
So we talked about Datadog and their monitoring and stuff before.

00:07:59.360 --> 00:08:05.600
So Brian, we've talked a little bit about machine learning and AI taking over the world, right?

00:08:05.600 --> 00:08:06.700
Yes.

00:08:06.880 --> 00:08:07.040
Yeah.

00:08:07.040 --> 00:08:09.360
So here's a little bit more of it in a good way.

00:08:09.360 --> 00:08:21.580
So Datadog has their APM application performance monitoring stuff has a new watchdog auto detection engine that uses machine learning to alert you about performance anomalies in your application.

00:08:21.580 --> 00:08:23.040
That's cool, right?

00:08:23.040 --> 00:08:24.080
That is really cool.

00:08:24.080 --> 00:08:25.960
So it learns how your app normally works.

00:08:25.960 --> 00:08:29.640
It's like, whoa, you know, it's pinned this thing at 100% CPU for some reason.

00:08:29.640 --> 00:08:30.880
Something must have gone wrong.

00:08:30.880 --> 00:08:32.520
Or maybe it's totally flat.

00:08:32.520 --> 00:08:34.060
You're processing no traffic.

00:08:34.060 --> 00:08:35.480
Either way, you probably want to know.

00:08:35.480 --> 00:08:44.940
So with Datadog's new watchdog thing, you can explore and analyze all your app performance data, navigate between correlated metrics, traces, logs, all that kind of stuff in real time.

00:08:45.460 --> 00:08:55.720
So if you want to start optimizing your Python apps with machine learning, you can get a 14-day free trial and Datadog will send you a free t-shirt at pythonbytes.fm/Datadog.

00:08:55.720 --> 00:08:57.040
So that's pretty awesome.

00:08:57.040 --> 00:08:58.200
I'd like to check that out.

00:08:58.200 --> 00:08:59.520
Yeah, definitely cool.

00:08:59.520 --> 00:08:59.840
Yeah.

00:08:59.840 --> 00:09:02.360
We've talked about deployment once or twice, right?

00:09:02.360 --> 00:09:03.240
I think so.

00:09:03.240 --> 00:09:06.080
Along with our GUI kick.

00:09:06.080 --> 00:09:08.140
So here's an interesting take on it.

00:09:08.140 --> 00:09:15.020
So one of the things I think is challenging about distributing a Python application is you have to distribute your source code.

00:09:15.680 --> 00:09:23.400
Now, maybe you distribute the PYC files so you can distribute like a bytecode version, but it's pretty easy to unbytecode that, right?

00:09:23.400 --> 00:09:29.800
But there's not a lot of great ways to distribute your code if you are concerned that maybe someone will mess with it.

00:09:29.800 --> 00:09:38.560
Like you could put it onto, say, a web server, but if somebody breaks into the web server and they find your code, well, they could change simple things like your Stripe ID.

00:09:38.560 --> 00:09:44.180
So all of a sudden, all your purchases start deposited into their bank account instead of yours or things like this, right?

00:09:44.680 --> 00:09:48.780
So if you want to deploy your apps and protect them, that can be tricky.

00:09:48.780 --> 00:10:01.760
And it's extra tricky in Python because if we're deploying C++ or Go or even .NET, there's like compiled binaries and you can sign those so that they don't get, they can't run basically if they're not properly signed and things like that.

00:10:01.760 --> 00:10:04.120
But in Python, you distribute generally source code.

00:10:04.340 --> 00:10:15.140
So this next thing is there's this like consulting group company and they wanted to come up with a way to protect Python code for the people they work for.

00:10:15.140 --> 00:10:21.040
So they wrote this article and created this thing called Executing Encrypted Python with No Performance Penalty.

00:10:21.040 --> 00:10:21.800
Oh, wow.

00:10:21.800 --> 00:10:22.020
Cool.

00:10:22.220 --> 00:10:25.220
So, you know, we have the PYC, which is the bytecode thing.

00:10:25.220 --> 00:10:26.800
And that's just straight bytecode.

00:10:26.800 --> 00:10:30.860
But what they've created is what they're calling a PYCE file.

00:10:30.860 --> 00:10:38.760
And the PYCE file is an encrypted Python byte file, which until you decrypt it, can't be executed.

00:10:38.760 --> 00:10:40.360
So that's pretty cool, right?

00:10:40.360 --> 00:10:41.240
That's very cool.

00:10:41.320 --> 00:10:45.000
Yeah, and the way they make this work is they override the import statement.

00:10:45.000 --> 00:10:50.040
They basically import a library that changes what import means.

00:10:50.040 --> 00:10:55.640
So when you say import, it runs their custom code that says, oh, it's one of these encrypted files.

00:10:55.640 --> 00:10:58.520
Well, that means grab the decryption key, decrypt it.

00:10:58.520 --> 00:10:59.900
Now we load that into memory.

00:10:59.900 --> 00:11:06.060
And the no performance part comes from the fact that once Python has loaded a module, it's just in memory.

00:11:06.540 --> 00:11:10.860
And so the decrypted version's in memory, you hit it again, and it's golden, right?

00:11:10.860 --> 00:11:11.440
It just keeps running.

00:11:11.440 --> 00:11:15.220
So basically, it maybe starts a tiny bit slower, but then it's the same.

00:11:15.220 --> 00:11:18.320
So if this is something you're interested in, check it out.

00:11:18.320 --> 00:11:18.900
It's pretty cool.

00:11:18.900 --> 00:11:21.500
So is this a commercial thing or is it something there?

00:11:21.500 --> 00:11:24.220
I think it's open source on GitHub as far as I can tell.

00:11:24.220 --> 00:11:26.100
That's very cool.

00:11:26.100 --> 00:11:29.980
It is from a commercial company, like a consulting company.

00:11:29.980 --> 00:11:32.960
But I think, let me see if I can find the license.

00:11:32.960 --> 00:11:33.720
Do they have a license?

00:11:33.720 --> 00:11:36.520
The license is, wait for it.

00:11:36.600 --> 00:11:37.340
Actually, wait for GitHub.

00:11:37.340 --> 00:11:38.480
Come on, license.

00:11:38.480 --> 00:11:40.420
Apache 2.0.

00:11:40.420 --> 00:11:42.020
Yeah, permissive license.

00:11:42.020 --> 00:11:44.720
Yeah, so it's free for commercial use.

00:11:44.720 --> 00:11:46.080
This is a very cool thing.

00:11:46.080 --> 00:11:47.140
I'll have to check that out.

00:11:47.140 --> 00:11:48.020
Yeah, nice.

00:11:48.020 --> 00:11:53.120
Yeah, it's not being used by a lot of people, but it seems to me like the people who want this really want this.

00:11:53.120 --> 00:11:53.680
You know what I mean?

00:11:53.680 --> 00:11:55.420
Everybody else is like, why do you want that?

00:11:55.420 --> 00:11:56.200
I don't care about that.

00:11:56.200 --> 00:11:58.480
But if you really wanted it, it seems like it'd be pretty cool.

00:11:58.480 --> 00:12:00.440
So anyway, that's what I found for that one.

00:12:00.440 --> 00:12:00.800
That's great.

00:12:00.800 --> 00:12:01.700
Nice.

00:12:01.700 --> 00:12:02.220
Yeah.

00:12:02.900 --> 00:12:03.880
What's this next one about?

00:12:03.880 --> 00:12:06.000
I don't even know what to make of your notes here.

00:12:06.000 --> 00:12:06.660
This is crazy.

00:12:06.660 --> 00:12:07.280
It's cool.

00:12:07.280 --> 00:12:12.740
Well, actually, I just saw, this actually came in just this morning.

00:12:12.940 --> 00:12:21.240
I saw a tweet from Harry Percival saying that he wrote a plug-in for pytest called pytest-ICDiff.

00:12:21.240 --> 00:12:31.820
And it's a plug-in that allows you to use ICDiff for asserts that are equal comparisons in pytest.

00:12:31.820 --> 00:12:35.820
Right, like a failure in, say, like, assert these are equal, but then they're not.

00:12:35.820 --> 00:12:39.580
And it'll show you like a color diff instead of just, no, they're different.

00:12:39.580 --> 00:12:40.840
Yeah, that's pretty much it.

00:12:40.840 --> 00:12:41.520
I love it.

00:12:41.520 --> 00:12:49.440
And I have never even heard of ICDiff, but ICDiff apparently is a different diff that isn't necessarily tied to pytest.

00:12:49.440 --> 00:12:54.640
You can use it just on the command line for better diff, colored diffs.

00:12:54.640 --> 00:12:58.480
Yeah, IC stands for improved color diff, which is pretty cool.

00:12:58.480 --> 00:13:00.780
And it's a Python project in and of itself.

00:13:00.780 --> 00:13:04.220
And then it looks like Harry Percival's pytest-ified it.

00:13:04.220 --> 00:13:08.280
Yeah, it's cool that having some color there, highlight things.

00:13:08.280 --> 00:13:12.440
I think it's great because so often when a test fails, you're like, oh, what is going on?

00:13:12.440 --> 00:13:15.100
Like, you want to look at it and you're like, what is that?

00:13:15.100 --> 00:13:16.600
Is that, oh, there's that dot there.

00:13:16.600 --> 00:13:18.420
You know, like some color would really help, right?

00:13:18.420 --> 00:13:21.080
Yeah, to highlight exactly which part of it's different.

00:13:21.080 --> 00:13:21.760
Yeah, exactly.

00:13:21.760 --> 00:13:25.800
So that's a pretty short section, just a new tool that I thought was neat.

00:13:25.800 --> 00:13:26.500
I thought I'd share.

00:13:26.500 --> 00:13:29.620
Well, I don't know why you wouldn't use this if you're using pytest.

00:13:29.880 --> 00:13:33.040
Yeah, that won't help you for other types of asserts.

00:13:33.040 --> 00:13:38.540
But it's the equality of why is it not equal that really trips people up sometimes.

00:13:38.540 --> 00:13:39.120
Yeah, for sure.

00:13:39.120 --> 00:13:40.660
Yeah, it's great.

00:13:40.660 --> 00:13:41.560
Nice find there.

00:13:41.560 --> 00:13:42.600
And well done, Harry.

00:13:42.600 --> 00:13:45.680
All right, the last one is a bit of a amusing.

00:13:45.680 --> 00:13:47.880
And this was sent to us by one of our listeners.

00:13:47.880 --> 00:13:49.540
So thank you for sending this in.

00:13:50.000 --> 00:13:53.900
And I wasn't sure whether we should cover it, but I kind of feel like we should.

00:13:53.900 --> 00:14:00.360
So what they sent in to us is highlighting a .NET project, C#.NET.

00:14:00.360 --> 00:14:03.540
And you might think, Michael, why do we care about a .NET project?

00:14:03.540 --> 00:14:04.620
We don't really.

00:14:04.620 --> 00:14:09.560
But the parallels for what we could do in Python, this would make me do a backflip.

00:14:09.560 --> 00:14:12.280
I don't even know how to do it, but I'd give it a shot, even though it might hurt.

00:14:12.280 --> 00:14:17.060
So they said, hey, there's this project called Blazor by the .NET guys.

00:14:17.060 --> 00:14:20.540
And it was created by this guy by the name of Steve Sanderson, who's a really brilliant

00:14:20.540 --> 00:14:20.980
web guy.

00:14:20.980 --> 00:14:25.140
So what they're doing is they're using WebAssembly.

00:14:25.140 --> 00:14:31.140
And if you're unfamiliar with that, it's a new, it's kind of like JavaScript, but in binary

00:14:31.140 --> 00:14:32.540
compiled form.

00:14:32.540 --> 00:14:38.780
So it's a binary instruction format for stack-based VM that runs inside of web browsers.

00:14:38.780 --> 00:14:44.940
And it's designed as a portable target compilation for high-level languages like C, C++, and Rust.

00:14:45.780 --> 00:14:51.080
So instead of writing in JavaScript and then running that in JavaScript engine, like V8

00:14:51.080 --> 00:14:56.660
or whatever, you compile something like Rust or C++ or C into this WebAssembly stuff that

00:14:56.660 --> 00:15:00.440
is then executed more or less natively in Firefox, Edge, Safari, and Chrome.

00:15:00.440 --> 00:15:01.960
So all the browsers that really matter.

00:15:01.960 --> 00:15:05.580
So coming back to this project, Blazor.

00:15:05.900 --> 00:15:11.440
So what this is, is the .NET people and Steve Sanderson have found a way to take the entire

00:15:11.440 --> 00:15:16.580
.NET runtime, known as the CLR, and compile it to WebAssembly.

00:15:16.580 --> 00:15:22.100
And what's interesting about that is it's written entirely in C and C++.

00:15:22.100 --> 00:15:24.740
You know what else is written entirely in C and C++?

00:15:24.740 --> 00:15:26.200
Yeah, CPython.

00:15:26.200 --> 00:15:26.940
CPython.

00:15:27.500 --> 00:15:32.800
So what they've done is they've taken this thing, which is a native OS compiled thing,

00:15:32.800 --> 00:15:38.240
and they've turned it into something that runs on the client side in the browser natively by

00:15:38.240 --> 00:15:38.900
using WebAssembly.

00:15:38.900 --> 00:15:39.640
That's cool.

00:15:39.640 --> 00:15:40.200
That's awesome.

00:15:40.200 --> 00:15:43.100
And it even has what's called a head-of-time compile mode.

00:15:43.480 --> 00:15:49.440
So you can take your, in their case, .NET, my hope for the world Python code,

00:15:49.440 --> 00:15:54.220
and pre-compile that into WebAssembly binaries that you ship instead of JavaScript or source code

00:15:54.220 --> 00:15:55.140
or anything like that.

00:15:55.140 --> 00:16:01.720
And they even created a single-page app front-end framework with routing and unit testing and

00:16:01.720 --> 00:16:02.520
all sorts of stuff.

00:16:02.520 --> 00:16:06.700
So this is a really cool project that I think may inspire people to try it for Python.

00:16:06.700 --> 00:16:11.320
So what I still don't, I'm kind of, I hope people do try it for Python.

00:16:11.320 --> 00:16:12.140
I think that'd be great.

00:16:12.140 --> 00:16:16.020
I'm trying to, even Blazor itself, I'm trying to understand the use model.

00:16:16.020 --> 00:16:21.560
Is it, it's not, at that point, you're not doing client-server stuff with Blazor, I'm assuming, or is it?

00:16:21.560 --> 00:16:28.660
You could be doing client, so the real use of this is if you were thinking about using AngularJS,

00:16:28.660 --> 00:16:35.200
VueJS, React, React Native, any of these, like, JavaScript front-end frameworks where most of your app

00:16:35.200 --> 00:16:41.920
lives on the client side in the browser, like Gmail or Google Docs or Dropbox Paper or something like that.

00:16:41.920 --> 00:16:51.340
Instead of writing that in tons of JavaScript and executing through a JavaScript engine, Blazor lets you write that in C# and execute it natively at a much higher performance.

00:16:51.340 --> 00:16:52.040
Oh, okay.

00:16:52.200 --> 00:16:52.360
Yeah.

00:16:52.360 --> 00:16:54.820
So that's being accomplished by them.

00:16:54.820 --> 00:16:56.260
And it's already, they have working models.

00:16:56.260 --> 00:16:57.120
It's not like a theory.

00:16:57.120 --> 00:16:58.240
This is already working.

00:16:59.200 --> 00:17:09.500
So when we were at PyCon 2018 in Cleveland this year, one of the very first keynotes, a guy named Dan Callahan, I believe, may have misremembered his last name,

00:17:09.500 --> 00:17:10.980
but worked for Mozilla.

00:17:10.980 --> 00:17:20.260
And they basically laid this path out for Python and called for this to exist, said, look, there's WebAssembly, there's C code, CPython.

00:17:20.760 --> 00:17:23.920
We need CPython in the browser.

00:17:23.920 --> 00:17:28.960
Obviously, it can't do things like connect to databases or do other weird stuff that the browser won't allow.

00:17:28.960 --> 00:17:34.820
But a vast majority of what you want to do in Python or JavaScript could be done in Python and faster and better.

00:17:34.820 --> 00:17:35.280
Yeah.

00:17:35.280 --> 00:17:36.540
Oh, that'd be cool.

00:17:36.540 --> 00:17:36.900
Okay.

00:17:36.900 --> 00:17:38.020
So that's really cool.

00:17:38.100 --> 00:17:42.180
And I linked to his YouTube video that is the keynote where he lays this out.

00:17:42.180 --> 00:17:43.500
It's like a 45-minute talk.

00:17:43.500 --> 00:17:47.260
And the foundations of it, he actually references this in the video.

00:17:47.260 --> 00:17:55.140
A lot of the foundations for WebAssembly itself come from this thing called ASM.js, A-S-M as in assembly, dot JS.

00:17:55.140 --> 00:18:01.620
That's an interesting project that preceded it that will let you take, like, C code and run it in the browser by compiling it to JavaScript.

00:18:02.340 --> 00:18:07.480
So Gary Bernhardt has this amazing fictional presentation that is very educational.

00:18:07.480 --> 00:18:13.560
And the tech part it teaches is real, but it has, like, a story around it called The Birth and Death of JavaScript.

00:18:13.560 --> 00:18:18.040
So that's the proper pronunciation in his fake world.

00:18:18.040 --> 00:18:20.240
And I linked to that video as well.

00:18:20.240 --> 00:18:27.900
And it's just, it's super insightful on how, like, ASM.js and WebAssembly can bring things in to this.

00:18:27.900 --> 00:18:32.260
So, like, he has something insane, like, a macOS running Firefox.

00:18:32.260 --> 00:18:37.560
And in Firefox, there's, like, Windows running, which is running Chrome.

00:18:37.560 --> 00:18:41.700
Or something super, like, Inception-like based on just this ASM.js.

00:18:41.700 --> 00:18:42.940
And WebAssembly could go farther.

00:18:42.940 --> 00:18:43.840
So it's really cool.

00:18:43.840 --> 00:18:44.160
Nice.

00:18:44.160 --> 00:18:44.600
Yeah.

00:18:44.600 --> 00:18:47.220
Anyway, just wanted to give sort of a highlight to that project.

00:18:47.220 --> 00:18:53.000
I think actually creating this myself is probably beyond my understanding of CPython.

00:18:53.000 --> 00:18:54.360
But I would love for this to exist.

00:18:54.360 --> 00:18:54.620
Yeah.

00:18:54.620 --> 00:18:56.900
And then we'll have to hit you up on that backflip.

00:18:56.900 --> 00:18:57.540
Yeah, exactly.

00:18:57.700 --> 00:19:00.020
I will do it maybe on something soft.

00:19:00.020 --> 00:19:02.160
Maybe in a gymnastics place.

00:19:02.160 --> 00:19:03.140
But, yeah, I'll definitely do it.

00:19:03.140 --> 00:19:03.460
All right.

00:19:03.460 --> 00:19:05.600
So very cool project.

00:19:05.600 --> 00:19:09.900
It's not directly relevant, but it has massive parallels in the Python space.

00:19:09.900 --> 00:19:10.480
So that would be cool.

00:19:10.480 --> 00:19:12.720
Anything else you want to share with us, Brian, while we're all here?

00:19:12.720 --> 00:19:13.440
No, I'm good.

00:19:13.440 --> 00:19:13.860
Nice.

00:19:13.860 --> 00:19:14.340
How about you?

00:19:14.340 --> 00:19:15.580
I want to share two things.

00:19:15.580 --> 00:19:20.600
One, we were talking before about my Building Data-Driven Web Apps course that's being well-received.

00:19:20.600 --> 00:19:24.260
If you want to learn about building data-driven web apps in Python, check that out.

00:19:24.260 --> 00:19:25.280
Put the link at the bottom.

00:19:25.740 --> 00:19:33.140
Another one, someone sent in on Twitter to us just highlighting Guido Van Rossum's final presentation.

00:19:33.140 --> 00:19:45.100
At the time, I don't think that he knew that it was his final presentation, but he gave a sort of closing the conference talk at PyCascades called a Python 3 retrospective.

00:19:45.200 --> 00:19:52.020
And so just highlighting, like, here's his last official as BDFL presentation might be interesting to some people.

00:19:52.020 --> 00:19:52.560
Yeah.

00:19:52.560 --> 00:19:53.340
Yeah, it was a good talk.

00:19:53.340 --> 00:19:53.780
I was there.

00:19:53.780 --> 00:19:54.180
Okay.

00:19:54.180 --> 00:19:55.260
I'll have to check that out.

00:19:55.260 --> 00:19:55.860
I haven't seen it.

00:19:55.860 --> 00:19:56.620
Yeah, yeah.

00:19:56.620 --> 00:19:57.100
It's pretty good.

00:19:57.100 --> 00:19:57.880
All right.

00:19:57.880 --> 00:20:01.280
Well, Brian, thanks for being here and sharing everything you have.

00:20:01.280 --> 00:20:01.720
Oh, yeah.

00:20:01.720 --> 00:20:02.100
Thank you.

00:20:02.100 --> 00:20:02.400
Yep.

00:20:02.400 --> 00:20:02.680
Bye.

00:20:02.680 --> 00:20:02.960
Bye.

00:20:03.660 --> 00:20:05.280
Thank you for listening to Python Bytes.

00:20:05.280 --> 00:20:07.840
Follow the show on Twitter via at Python Bytes.

00:20:07.840 --> 00:20:10.740
That's Python Bytes as in B-Y-T-E-S.

00:20:10.740 --> 00:20:14.180
And get the full show notes at pythonbytes.fm.

00:20:14.180 --> 00:20:18.500
If you have a news item you want featured, just visit pythonbytes.fm and send it our way.

00:20:18.500 --> 00:20:21.200
We're always on the lookout for sharing something cool.

00:20:21.200 --> 00:20:24.600
On behalf of myself and Brian Okken, this is Michael Kennedy.

00:20:24.860 --> 00:20:28.220
Thank you for listening and sharing this podcast with your friends and colleagues.

