Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 63, recorded January 31st, 2018.
I'm Michael Kennedy.
And I'm Brian Okken.
And as always, we've got a bunch of stuff lined up for you.
Before we get to it, let's just say quickly thank you to DigitalOcean for making this show possible.
Thank you, DigitalOcean.
You want to check out what they're offering, do.co slash Python.
I'll tell you more about them later.
Right now, I want to hear a little bit about what's coming in Python, Brian.
We've already talked about data classes coming up in Python 3.7 already.
And I was curious about, you know, exactly what that means to how it'll be to work with them and stuff.
And Anthony Shaw put together a tour of how they work.
And it's a pretty quick read, but it's a pretty good thorough understanding of it.
I guess it's called A Brief Tour of Python 3.7 Data Classes.
And there's some exciting things.
Like, one of the things is there's a lot of the default magic methods that I'll put in place are like init and represent or repr.
I don't know how you say that.
And the dunder stir and dunder equal.
The equal one is the thing that I think is really kind of cool is that it's going to compare all the attributes in order.
So if all of the elements of your data class are equal to another object with the same elements, they will be equal.
And that's not something that's normal by default.
So that's good.
Yeah, actually, that's really cool.
And I wonder, I don't know, there's a couple things that are interesting to me here.
One is the default value stuff, the way that you can configure the fields, the fact that there's type annotations coming as basically, are those required?
It looks like they might be required, not just optional.
They are required, but if you don't know what a type will be, there still is the, in the types, there's an any type that you can use?
Yeah, so basically, that's like the void star or whatever.
Like, I have no idea what this is.
Just, it's a thing.
I mean, this is Python.
So a lot of times you want it to be generic.
You don't know what the type's going to be.
Yeah, yeah, that's right.
That's right.
It's pretty interesting.
So I do like these.
The other thought I had about these, looking through this, is I wonder if this means the name tuple is less cool these days.
What do you mean?
Well, one of the things I think that's nice about the name tuple is you can basically create a type, and you say it has these fields, and then you have sort of typed access to it.
In the editors, you hit dot, and you get a dropdown of all the available elements of that thing.
You can make it read-only, which is potentially nice.
What else?
It has a nice string representation.
It has a nice hash and equals operator, right?
All those types of things.
Every one of those comes in data classes.
And if you put a frozen on the data class attribute to say, actually, this is read-only, then it also implements the hashing.
It has the immutability feature.
Like, once it is created, it looks like it is the sort of equivalent of a name tuple.
But it's richer in the sense that you can have, like, default-generated values.
It has...
It just seems a little richer than a name tuple, but its usage is pretty much the same.
I think in my case, I probably will use it.
I'll try to use it more to see how I like it.
But, I mean, right now, I use name tuples quite a bit, and they're...
Yeah, they're very...
They're very terse.
There's, you know, a couple lines of code, and you've got a new type.
Yeah, the one thing I do see here is, like, with name tuples, you can literally, on one line, have a type that takes six arguments.
Whereas this one, you know, it's certainly more verbose.
But once it's defined, I feel like, basically, the use case is, like, this is a super set of name tuples, unless I'm missing something.
Yeah, I definitely think in the use case, a lot of places where name tuples are being used, data classes will be used instead.
It'd be interesting to see if there's any different performance for data classes versus regular classes.
I think you can say use slots.
Is that possible?
I think that might be a thing.
That, I'm not sure.
Anyway, if you can do that, that would actually have a really interesting impact as well, because that would probably use less memory than name tuples.
At least my testing has shown that it does.
Well, I'm sure that there will be somebody that goes out and does some performance analysis.
Of course.
Give us that answer.
Yeah, it's a call to the audience, indeed.
Very, very cool.
So these are coming, and that's pretty neat.
I have another piece of news for you related to this.
Okay.
So Python 3.7, development on it is, like, sort of frozen in the sense that it's now out for testing and for usage, but no new features are being added to it.
So it's kind of frozen.
And Python 3.8 development started yesterday.
Wow.
Yeah, so I haven't started testing with 3.7 yet, or doing any of that.
Have you used it at all yet?
No, I've thought about it, but I haven't done it now.
Yeah, definitely something I want to get started on here pretty soon, because I think it's due to drop in, like, June or something like that.
Yeah, it's in, like, a trial period to make sure the world doesn't break when it gets released, because could you imagine the pressure?
But, yeah, it's supposed to officially come out in June, but it's kind of gone into its testing mode, which is pretty cool.
So if I ask you, what was the most popular database in terms of deployments, what database would you guess?
Oh, I've fallen for this before.
I'm going to answer Excel.
Excel.
Is that actually, you know, I don't know.
This one that I'm about to say, it was very likely to give even Excel a run for the money.
So everybody who has Python has SQLite, right?
It's baked in.
There's a whole bunch of things that are interesting about SQLite.
So it's like an in-process database.
If you want to do something relational, say, with, like, SQLAlchemy or something, but you just want to ship some, a little app, you don't want to deal with, like, a client-server model, SQLite is so super nice for that, right?
You just have, like, a little data file.
And I think we maybe talked about this a little bit before in a couple shows back, but one of the listeners sent in this thing, this series from Carnegie Mellon University called the Databasology Lectures.
So there's a bunch of databases covered there, and there are actually quite a few interesting ones.
And the idea is these are, like, hour, hour and a half long academic lectures by the creators of various databases about the internals of how they work.
And I think it's more or less like a CS sort of either speaker series or actually a course.
I'm not sure, but they got a bunch of luminary folks to come and speak about it.
And it's pretty cool.
So they have, like, the guy.
That sounds like an exciting date night.
Oh, yeah.
Yeah, my wife was pretty excited when I suggested that.
No.
So there's WiredTiger, which became the foundation of the storage engine of MongoDB.
They had that before it became part of Mongo.
Okay.
The one that I wanted to call out is the one by Richard Hipp, who is the creator of SQLite.
And it's like this deep look inside the architecture and tradeoffs and design decisions of SQLite.
And so if you're interested in databases, you're interested in how SQLite works, there's a bunch of optimizations and tradeoffs you can make around, like, durability versus performance.
There's a bunch of sort of deep dive stuff into here.
So I thought that was pretty cool to highlight.
I'll definitely check that out.
I also noticed that they've got even SAP in Oracle.
That'd be interesting.
Yeah.
Something to do with Berkeley DB in there as well.
So, yeah, it's quite cool.
Yeah, but there's just so much I'm not really sure I want to try to cover it.
But if you want to look inside of, like, how do the B-trees map to disk and how do they deal with, like, power failure, transactional durability, and all that kind of stuff, you want to see a deep look inside of that for databases in general, SQLite in particular, you check it out there.
I guess one, just as a teaser, one interesting fact that came out of there is SQLite is shipped as a single C file.
Yeah, that's cool.
I don't know how, like, two million lines?
I don't know, like, some insane number of lines.
They don't develop it as a single.
No.
No, there's some process, some mechanism that, like, detangles all the, you know, include statements and the various compile orders and all of that stuff.
And it, like, generates this one huge file with, like, no dependencies.
But it's pretty wild to think of such a program as created that way.
It's interesting that it's intentionally no dependencies.
The whole thing is a little bit unusual.
The way that the guy has created it and run it.
Like, instead of, he was like, well, open source is good.
But actually, I just want to make it like nobody.
This is a thing that just is the world.
And so he made it, put it out there under common domain or what's that called?
Anyway.
Where you just say, like, it belongs to the world.
I relinquish all ownership of this thing.
It is just now public domain.
Public domain.
Yeah.
So it's pretty interesting.
Yeah, it is.
Do you know what else is interesting?
Testing your code before you take down the system?
Or you charge a credit card and you didn't want to?
Yeah.
Did we get this from a listener?
I can't remember.
Yeah, this definitely came from a listener.
I can't remember who.
Maybe I'll pull that up while you're having a look.
Okay.
Well, this is a project called Dryable.
A useful dry run decorator for Python.
And the idea is that there's some times where you want to run your entire application, but there's pieces of it that you don't want to run all the time.
Like in their example, they've got, if you're accessing an outside database with requests or something like that, you can turn that off during your dry runs.
And I really like how generic this is.
Basically, you put a decorator, it's a dryable decorator you put on top of a function.
And then when you set the dryable state to true in your code, those functions just don't do anything.
And then they also have the option of specifying a default return value.
So during your dry runs, if the function that you're turning off is supposed to return something or else the rest of your code is just going to break, you can specify that there.
And for testing certain systems, I think this is an awesome idea.
And it's pretty cool.
It's pretty easy to start.
It's almost like if I wanted to set up the mocking story for my code by using decorators, and I could run it just even outside of a test framework, like what would that look like?
It looks like this dryable thing, right?
The intent, I think, is to be able to just leave this stuff in your code.
So it's a very minimal impact.
And then you can just, if you want, you can just leave it there so you can always be able to do dry runs or something.
Yeah.
In your test code, you just say dryable.set true.
And then it just goes in the hood.
So one of the things I was wondering about when I saw this, I agree that it's cool and I definitely like it.
But one of the things that I was wondering is like, we have mocking stuff.
And these other mechanisms for stubbing out stuff.
Like, where do you see this fitting in versus not?
A lot of times people, and I agree, mocking and monkey patching is often used for testing stuff.
But like, I don't know, for example, you could put together, we were doing different GUI applications we were showing the other day.
If you wanted to attach a GUI to a database system, you could have a mocked up database set to just let people play with user interface.
And that's not really a testing thing.
It's you're just using something with some dummy data in the back end.
Something like that would work.
I see like maybe some, if you're trying to build out the UI and you don't have the data yet, it would be really nice to just go and here's some data to work with until we get there.
Yeah, yeah, definitely.
Yeah, okay.
That's pretty cool.
So I told you about DigitalOcean at the top of the show.
And I'll give you a little more details.
They actually have some super exciting news.
Maybe a week, week and a half ago, two weeks ago, I can't remember.
But I actually spent a lot of time upgrading a bunch of servers because DigitalOcean is awesome.
They actually went and said, you know what?
All that money that you're paying for the servers, we're just going to double all the things.
You have one gig of RAM and you're paying us $10 a month.
All right, now you get two gigs of RAM.
You have one CPU and you're paying a certain amount.
Now you get two CPUs or two to four.
So they basically, not everything, CPUs not quite as much, but certainly, you know, disk size with SSDs,
the RAM, to some extent, the CPUs, they're basically doubling everything they offer.
So now you can get like a server with a gig of RAM and a CPU and 30 gigs, 50?
I don't know, 50 gigs of SSD for $5 a month.
How insane is that?
Wow.
Yeah, exactly.
So anyway, it's really cool that the new pricing that they put out.
So definitely drop over do.co slash Python and check that out.
Because if you thought it was good before, like literally they doubled most of the things for most of the tiers.
That's great.
Yeah.
So really nice.
And Python Bytes now delivers itself just a tiny bit faster and has, you know, a few more gigs of RAM to do it with.
Well, that's good because our listeners are going up.
Right.
We got to keep up with the demand.
Thank you, everyone.
Speaking of demand, we got actually a lot of listener feedback for the show.
And I think that that was really great.
Like, please keep the recommendations coming on Twitter and email and so on.
Have you noticed I've been on this gooey kick lately, Brian?
We kind of knew this was going to happen.
We claimed that there weren't any good solutions.
And then people told us.
Yeah.
And I still mostly stand by that.
But there are people doing really cool things.
And I just want to highlight them.
So a guy named Victor Domingos said, hey, look, I'm not really much of a programmer.
I kind of like an engineer or something.
You know, he was doing something else, but he needed to do some program to build this thing.
Right.
But I disagree with that.
Steve, I think he's quite a programmer building these things.
So he sent us three examples of some apps that he built in Python.
And I don't know.
Do you click those and pull them up, Brian?
See the pictures?
I'm trying to pull up one now.
Yeah.
So what's really nice is, like, it's all screenshots.
Which, by the way, if you have a UI framework and you want people to admire your UI framework,
screenshots.
Yes.
Pictures, please.
Just describing how awesome it is in text doesn't actually make it awesome.
But these look like rich, interesting applications.
And I definitely think what he's doing here is quite neat, especially the first and the
second one that we've linked.
So he linked to three.
This is crazy.
PT Tracking is both.
It's got both the desktop application, which looks nice.
And an iPhone version.
Yeah, it's pretty interesting.
I mean, like I said, this guy built some really powerful stuff, right?
Yeah.
Looks great.
What's even better is it's open source, right?
This is TK Enter code.
And he's like, look, you're giving TK Enter a bad rap.
This is actually could be more nice looking if it's built the right way.
And by the way, here's three open source apps I built that you can check out with screenshots,
by the way, which is very nice.
So I just want to highlight that.
Say thank you, Victor, for sending these in.
Share the links he sent because they are pretty inspiring.
And they're working examples.
I did not know you could make an iPhone app with TK Enter.
I still don't even know how that works.
I don't either.
Maybe I'll try this out.
Maybe there's some kind of PEP for it.
Like a pep.
What is that?
Pep 7.225.
Make Python build desktop or mobile apps on iPhone.
Is that what it is?
What if there's like a way you could figure this out that we could settle this debate?
There's Pep Explorer.
And it is by Anthony again.
Anthony Shah that we gave him credit on the first article that we talked about.
But Pep Explorer.
Explore Python enhancements with a web interface.
It's got a search function.
And you can look at all sorts of stuff.
There's even in the status.
I don't quite get all the status ones.
But there's an April Fool status, which I didn't know about.
That's pretty awesome.
In 2009, they pretended that BDFL was retiring.
It probably just scared people, actually.
That's really what happened.
Yeah.
So not only do you find the peps that were accepted, but you can search and say, show me
the ones that were either deferred or rejected.
You probably will learn a lot of interesting stuff by seeing what is rejected and why.
Yeah.
And then the ones that are still in draft form and everything.
One of the things I want to...
I had already picked this, and then I was playing with it.
Because the data classes that we talked about earlier, I cannot find on this little cool
tool here.
So I'm not sure what's going on with the 3.7 stuff.
Maybe 3.7 just isn't in here yet.
Yeah, maybe.
And this is a search engine sort of thing with data backed on GitHub, right?
And so if anybody wants to say, oh, you're missing this one, PR.
Yeah.
So nice people do fix it and do a PR.
I just am going to call them out on Python bytes and say it's broken.
This one doesn't work.
It's not there.
And I can't do a PR right now because I'm recording a podcast.
Yeah, definitely.
Yeah.
Nice work, Anthony.
You know, enough to get a double feature.
Very, very cool.
So I want to round this out with just a little bit more UI stuff.
If I'm going to show you all those pictures of cool apps that Victor built, the other thing
I want to sort of pair with that is a TK Enter tutorial from this.
We got on Twitter as well from at like geeks.
And it's basically here's how you go through TK Enter and create your first GUI application.
You don't really build anything too complicated or too advanced.
It's more like let's put some labels and buttons and combo boxes and progress bars on and see
what that looks like.
Right.
It's still like a decent distance from what Victor had built.
But if you are inspired by topic four, maybe topic six can help you take some steps in
that direction.
Yeah.
Okay.
Yeah.
It's pretty, pretty comprehensive.
Like it really covers most of the widgets and how to use them and stuff like that in Python.
So yeah, pretty cool.
This may, may be the final thing we say about it, or maybe my own news actually will cover
one more GUI thing.
Yeah.
I think that we have, we'll probably hear some more GUI things coming up in the future.
Yeah.
I'm okay with that.
I am too.
And I think this is great.
Like I think the other area that's looking really strong, the more that I talk to people
about this is WX Python.
Yeah.
What I didn't realize is WX Python has a project called WX Python Phoenix, where it was reborn
from the ashes of WX Python.
And there's like two versions of it, sort of.
So there's like a more modern version that I like conflated with the older version.
Okay.
Didn't know about that.
Yeah, I didn't either.
But the thing I'll tell you about in a second, dude, how about you?
Any other personal news you got going on?
Anything cool?
Not right now.
Nice.
For me, this is like the week of the recording, the recording.
So I'm recording six podcasts, talk Python, Python bytes.
I was a guest on a podcast and also a webcast.
So I did like an hour and a half webcast where I rebuilt PyPI in MongoDB, which was really fun.
Wow.
So it was really, really cool.
And I even created this fake database with like, you know, hundreds of thousands of records to make it act real.
It took like 15 minutes for the program to actually generate the database, but that was okay.
It was still good.
Anyway, so that was fun.
I'll put a link in there.
This weekend, some friends were over and they're like, hey, I'm trying to build this little script and it's almost working.
Can you help me?
And I'm like, oh, this is a cool little CLI.
But do you know what would be better is if it was a GUI.
It's like, yeah, I know.
You can't do that in Python, Kane.
You're like, yeah.
Hold on.
Like, let's pip install GUI, G-O-O-E-Y, the thing we already talked about.
And that thing is slick.
Let me tell you.
Basically, you create one of these argument parser things from GUI.
You say it takes these parameters and then you say get the parameters.
And that actually shows the UI with all the widgets filled out and the names and the types.
Like this one is a combo box.
It has these three items.
Like that's your argument.
Then it becomes just a combo box.
It really is like just a few lines of code.
It's awesome.
We've been getting a lot of people that have been using GUI show us their screenshots of
something they made with it in just a few minutes.
And that's pretty awesome.
I really think the bang for the buck is quite high on GUI right now.
And that's WX Python, by the way.
Also, a quick announcement on the courses.
I have a bunch of courses coming up and more of them are getting planned all the time.
It's really fun.
But I just launched a sort of business option team purchase page.
All the bundles and the courses and stuff at Talk Python Training.
Now have a buy this for your team.
And if you pick like however many people are on your team, it'll automatically apply like enterprise discounts and all that kind of stuff.
So if you want to go in there and say buy this for 10 people, it's all totally self-service now.
Wow, that's great.
Yeah.
So trying to make it easy for people to get more of that Python knowledge.
Yeah.
All right.
Well, thanks, Brian, for finding all these things and sharing with me.
Yeah.
Thank you.
Yeah.
Bye.
Thank you for listening to Python Bytes.
Follow the show on Twitter via at Python Bytes.
That's Python Bytes as in B-Y-T-E-S.
And get the full show notes at pythonbytes.fm.
If you have a news item you want featured, just visit pythonbytes.fm and send it our way.
We're always on the lookout for sharing something cool.
On behalf of myself and Brian Okken, this is Michael Kennedy.
Thank you for listening and sharing this podcast with your friends and colleagues.