Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book


Transcript #345: Some Big Time Releases

Return to episode page view on github
Recorded on Wednesday, Jul 26, 2023.

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

00:04 This is episode 345, recorded July 26th. Is that right? July 26th, 2023. I am Brian Okken.

00:12 I'm Michael Kennedy.

00:13 And you know, 345 episodes, you'd think I wouldn't have to read that, but I still do because I messed up.

00:19 Anyway, a lot of fun topics today.

00:23 Our sponsors today are us.

00:27 The courses that Talk Python Training, we'll talk about those.

00:30 And the new Python People podcast and our Patreon supporters, of course.

00:34 Thank you, everybody, for continuing to support us.

00:36 And everybody that's listening to this, usually, so this is a Wednesday morning, but usually it's Tuesday at 11 Pacific is when we're recording.

00:48 And if you are around at that time, we'd love to have you join the show.

00:52 Just go to pythonbytes.fm/live, and you can see when the next episode is going to get recorded.

00:58 Yeah, Brian, I usually try to.

01:00 I'm not always successful.

01:01 Also, sometimes I just don't know.

01:03 I usually try to schedule the next live stream soon as we're done with this one.

01:09 Yeah.

01:09 And so if you go to YouTube, you can click notify me for just that event if you want to come to the next week's one or something.

01:15 So that's kind of the best way to know when the next live stream is.

01:19 Yeah.

01:19 Yeah.

01:20 And I appreciate people to show up and add comments.

01:23 It's nice.

01:23 So, Michael, why don't you kick us off with the first topic?

01:26 Yes, indeed.

01:27 This is a very, very exciting one.

01:29 So the next topic, the first topic is the third version of Cython, not CPython.

01:36 I didn't drop a P on accident.

01:38 Cython.

01:39 Many people know what Cython is, but I suspect sufficiently many don't that it justifies me saying what the heck it is.

01:46 So Cython, let's do a throwback, Brian.

01:50 This will be fun.

01:51 You've done plenty of C.

01:53 Do you remember inline assembler when like little sections of C code had to be like really close to the metal?

02:00 And so you would write like a little bit of assembly inside of a C function or make a function in assembly and call it something crazy like that.

02:09 We're talking like 90s.

02:11 Yeah.

02:11 Well, Cython is kind of like that for Python.

02:13 If you've got some part of your code that's not fast enough, well, one of the options is to do what a lot of people are doing is go like, well, I'm going to go learn Rust and I'm going to write this section in Rust and then I'm going to import it into Python.

02:26 And there are certainly tools for doing so.

02:30 But what if you could write Python and make it as fast as C almost?

02:35 And that's what Cython is.

02:36 And it's kind of like this inline bit, like this function or this module, I need to be in closer to C speed farther from Python speed, especially in the math type of scenario.

02:49 So that's what Cython is.

02:51 It lets you write Python code that gets compiled to C and use very, very slight variations in the Python syntax.

02:59 It used to be way different.

03:01 You'd have to have your own types and they were imported from Cython.

03:06 So instead of having a traditional PyObject derived integer type, you would actually have a Cython int, which was like a local int, and you would express that in different ways.

03:17 And they've been moving towards what they call pure Python mode, where the code that you write for Cython is actually still valid Python if you wanted to just run it that way.

03:29 And that's pretty cool, right?

03:30 Yeah.

03:31 That involves things like type int.

03:33 So if you want to say, oh, here's a thing that's an int, instead of importing some specialized int type from Cython, you would just say x colon int.

03:40 And guess what?

03:41 That's how it works in modern Python.

03:43 So the news for this week is that Cython goes 3.0.

03:47 And this news comes to us from, let's see.

03:52 Oh, no, I ran across this with other ones sent over.

03:54 They're both new releases with lots of details.

03:57 So sorry.

03:57 Yeah.

03:57 So anyway, this one, the headline here is this is long in development.

04:01 That's in like five years.

04:03 It's been working on this.

04:04 And so it sheds legacy Python support.

04:08 That is Python 2.

04:09 Look, see that legacy Python.

04:11 People are starting to adopt our term.

04:14 I don't know if we have anything to do with it, but we should have tried to popularize that view of Python 2, didn't we?

04:19 Yep.

04:20 And it has a lot of boost for this pure Python mode that I talked about.

04:25 So you might say, okay, well, that's interesting that you have this pure Python mode, but why would I really care?

04:30 Because if the goal is to make it faster, I don't want to run it in pure Python.

04:35 I want to run it in Cython.

04:37 So compile it to see and then, you know, behind the scenes is part of your building of the wheel and all that.

04:42 Yeah.

04:43 The reason you might want to do that is what if you care about mypy or you care about Rough or you care about Black or all these other tools that are Python tooling to understand the Python code or even PyCharm or VS Code.

04:58 Right.

04:58 You want it to look at that and be able to lint it and format it and understand it.

05:03 Right.

05:03 So the pure Python mode allows you to do things like keep your linting tools.

05:08 Right.

05:08 So yeah, and also just there's been discussions basically that if we had type hints when Cython started, they probably would have used them to start with instead of their own thing.

05:20 Yeah.

05:21 Yeah.

05:21 They had no alternative.

05:22 So they came up with something.

05:23 It's just interesting that it kind of came.

05:26 I mean, I guess it compiles to see.

05:27 So it makes sense that it had like a really strong C flavor in the way that you wrote it.

05:31 Yeah.

05:32 Yeah.

05:32 So what else is notable here?

05:35 It said there's major NumPy support improvements.

05:39 So Cython's have worked well with NumPy, but now with Cython 3, it gives you the ability to write NumPy ufunks.

05:46 Don't do enough NumPy to know the why I care about ufunks, but you can write them directly in Cython.

05:53 So my understanding is basically that instead of going through the Python API and layer to work with NumPy, it drops down to the C layer.

06:03 And so it's like C to C interoperability when you're doing NumPy within Cython.

06:07 That's pretty cool.

06:08 Another thing that's not mentioned in this article that I'm linking to on InfoWorld that's really cool about NumPy, about Cython, is you can remove the GIL.

06:18 You can go no GIL.

06:19 There's a context manager that's just called no GIL.

06:22 So I can say, like, with this section, I'm going to do a bunch of code, and I want to release the GIL for other parallel processing stuff.

06:31 So if multiple bits of code call that into that function, and they're being done within threads, they can run truly in parallel on hardware right on the cores, right?

06:42 True OS thread parallelism, which is pretty excellent.

06:44 Now, the limitation there is that you can't be working directly with the Python API, right?

06:52 Like, say, list or something, because those assume that they're thread safe because of the gill, right?

06:57 But if you're just doing, like, your own algorithm, right, then you can, which is pretty cool.

07:01 And, yeah, that's pretty much it.

07:04 So well done, folks, on that.

07:06 It sounds like a ton of work, but, yeah.

07:09 If you are interested in Cython, check this out.

07:12 Bye-bye.

07:12 Cero in the audience says Cython is great for waiting for HPY output.

07:18 Nice.

07:19 Mm-hmm.

07:19 All right.

07:21 Well, that's number one.

07:21 Okay.

07:22 Which is actually number three.

07:25 Oh, yeah, because it's Cython 3.

07:27 Exactly.

07:28 So I want to talk about reading code.

07:31 And I kind of agree.

07:33 So this is an article by Eric Mathis, and he's the dude that wrote Python Crash Course.

07:39 And it's on its third edition now.

07:42 It's a pretty good book.

07:43 Anyway, reading code, an important but seldom discussed skill.

07:47 And I have to agree with that.

07:49 I've had many discussions in the past about coding standards within teams.

07:56 And I try to have them be lightweight.

07:59 It's better to just teach people how to read code.

08:02 And so I'm mostly bringing this up because I definitely agree that we need to talk about it more,

08:09 especially when teaching people, reading code and reading.

08:13 Like, we often tell people go out and read the source code for some popular third-party libraries or packages

08:20 or even the internal Python, standard Python library.

08:26 But it does take some skill to read code.

08:29 So anyway, he takes an example of a lottery example or something.

08:35 It doesn't really matter.

08:36 But there's a few techniques, a couple techniques that he lists that I really like.

08:41 So if you just look at code, you've got a whole bunch of comments.

08:45 You've got a whole bunch of stuff going on often.

08:47 And one of the things he says to start with is ignore the function definitions, which is interesting

08:53 because the function definition is where the name of the function is.

08:56 But just sort of ignore that for now.

08:58 And he doesn't say this, but in his example, he said, ignore all the comments.

09:04 I mean, he took out all the comments and the function definition.

09:06 And just so that you can just see the code and not everything else.

09:10 And I actually, I had a code base once where I had, there were so many comments that I wrote a little script

09:16 that would strip the comments out so that I could read the code better.

09:19 Anyway, it does, it's a, you can mentally do it when you, when you're kind of have a,

09:23 when you get used to doing this.

09:25 And also IDs help, but that's a great way to just sort of simplify what you're looking at

09:31 so that you can mentally see what's going on.

09:33 The second technique is to simplify repetitive blocks.

09:37 Like in the example we're showing, there's a couple big print blocks.

09:41 And he, his example says, mentally, you can just lump this into print a message.

09:48 And, and that helps you.

09:50 And then there's really not that much code left when you're looking at it.

09:53 And so that, that he talks about trying to make sense of it.

09:57 I'm not going to throw any, I'm not going to discuss really what I think of the quality of the code he's showing.

10:04 It's fine.

10:04 But, and then the, the, the last thing, or one of the next to the last is to talk about using an IDE.

10:13 And so the, I do this a lot with many IDs.

10:17 I think all of them now.

10:18 You can, like, just instead of hiding the, the function definition, you can hide everything but the function definition on the, on a lot of functions.

10:27 And if, especially if you're, if you've got a whole bunch of helper functions that are cluttering up the, your workspace, you can, or in weird places, you can just hide them so that you can see.

10:37 So like in this example, we've got get winning ticket, check ticket, and make random ticket.

10:42 And then you, you can kind of see a part of one of the functions, but maybe I also want to see like one other function.

10:49 So if, especially if you're looking at two functions, you can hide the rest of them.

10:52 It makes it nice.

10:53 Yeah.

10:54 It usually goes under the term of code folding.

10:57 Yeah.

10:57 Code folding.

10:58 That's it.

10:58 Yeah.

10:59 But then off a great discussion of, think about this.

11:04 Think about that.

11:04 People are going to read your code and try to understand it.

11:07 So think about that when you're writing code.

11:09 So writing, writing readable code.

11:11 One of the things he didn't bring up that I want to make sure about is, so this technique of like hiding the function definition.

11:17 One of the things, one of the powerful things about this is because we have mentally, when we're reading code, at least when I am, and I think this applies to a lot of people, we believe the function name.

11:30 And we believe the variable name because somebody chose it.

11:34 But, so therefore it really needs to be accurate.

11:37 It should be, it's hard to name functions and variables, but sometimes they drift.

11:42 Sometimes the, like, it'll say like set name or something, but it does a whole bunch of other stuff.

11:48 So if it does a whole bunch of other stuff, you're going to have to change the name of the function.

11:52 Because if the function's name is not accurate, people are going to fold it up and just assume that's what it does.

11:58 So I would say, I would add to this, make sure your function and variable names are descriptive and change them when the body of the function changes.

12:09 So, yeah.

12:10 And it's interesting.

12:11 I just had Eric on Talk Python, which is not yet out.

12:14 So, you know, time travel podcast.

12:16 He was both there and is not there.

12:18 It's sort of an Heisen Eric sort of thing going on there.

12:21 But a couple thoughts on this.

12:23 I think if, it's kind of a big if in the comments or hinting towards this in the live stream as well.

12:29 If the naming is super good, I kind of prefer the second way, like collapse all the functions and then expand them.

12:36 As you're like, that's not clear what this is doing.

12:38 Like, let me dive into that.

12:39 Like, you know, print header.

12:41 Like, okay, well, we're going to assume that that prints the header and just go on, you know, or things like that, right, where it's pretty straightforward.

12:49 There's not a lot of, I wonder what the algorithm does there.

12:52 It's like, eh, not too much.

12:53 So then I like to kind of fold it down.

12:56 But if, I'm not sure that I would take away the function names.

13:00 I guess it would be like a unique IDE plugin where you could say like inline everything.

13:07 And even if there's repetition, just inline it and just like, you know, and then work backwards as a way to understand.

13:12 Don't do that in the main branch.

13:13 But that'd be interesting to do.

13:15 But kind of in the reverse, a lot of times what you'll end up with is a function that's like super long and poorly structured if you're trying to understand it.

13:23 If just reading the function name doesn't work, it's usually because it's a big glob of a mess, right?

13:28 Not always, but often.

13:29 And so the part where he says, comment out this, instead of having all the steps of like print the winning thing, and here's like the seven things it does, you just like have a comment, print the winning thing.

13:40 What I like to do for that is as I'm trying to understand it, I'll grab like that section and refactor to a function and say print the winner.

13:47 Grab the other part, refactor, print, print loser or something along those lines, right?

13:54 And it actually will start to have the same effect as like replace it with a comment, but you end up with running code that is still like understandable and consistent as you kind of like play with it.

14:04 So I'll go through something like big and go, okay, this section, this should be its own little thing with a name.

14:09 Hey, how about I can make a function that has that name and the IDE just a highlight, right click, you know, control T or whatever.

14:16 Do it and give it the name that you were going to make the comment.

14:19 And that works a little bit better for me because it doesn't destroy the running code in case you're like, well, but now I need to run it to see what this other part does.

14:27 Yeah.

14:27 Yeah.

14:27 Another thing that you're, I was thinking of other tips when I, so I learned to program mostly doing a lot of C code and in there you've got to, you've got to have, if you're writing helper functions, they need to go ahead above the, the normal, the other function.

14:43 So that like, because it's not declared when it has to be visible to the function, that's not true with Python.

14:50 And, and so I've liked to have the reverse.

14:54 So if I've like, one of the suggestions is to break out, if you've got a bunch of helper functions and it's confusing you to put them in another file.

15:01 I don't actually like to do that, especially if it's only one file using it, I'd rather put it, put them below the, the function that they're helping.

15:10 and especially if there's just a couple main, functions that are used in this module that are the, that are used externally, but those I'd like to put those at the top and then all the helpers at the bottom or something like that.

15:23 I used to have a coding style to do the reverse and I think it was inherited from C code style, but, Python's different.

15:34 and I, I don't necessarily, I, I guess I, I'm not sure what I feel about the, hiding the function name, but I guess maybe don't trust the function name.

15:44 Yeah.

15:45 Verify.

15:46 yeah, there's a couple of comments like that.

15:49 David pool says a quote I once read is if the code and comments disagree, both are wrong.

15:53 That's kind of similar to the function names as well as given sufficient times, the code and the comments, maybe function names as well.

16:00 We'll start to lie, which is interesting there.

16:02 What?

16:03 And I also see that people are like more reluctant to change somebody else's comment than they are to change their code.

16:08 And I'm like, you gotta get over that.

16:11 If the comments are on, go feel free to change it.

16:13 That's, that's a perfectly fine refactoring.

16:16 So anyway, yeah, let's move to the next.

16:18 Absolutely.

16:18 I, I totally agree with you about putting the most sort of the organizing, coordinating high level stuff first.

16:24 you know, maybe what would be in the dunder, if, if name, dunder name equals dunder main, whatever that is, make that a function and put it at the top.

16:32 I, I totally agree that that's the way to go.

16:35 Yeah.

16:35 Cool.

16:36 All right, next, how about another release this time?

16:39 Something very small with lots of, lots of effort.

16:42 So this is the one that I was thinking that comes from Matt Trentini and let me pull it up.

16:49 Cause that's some good stats in it.

16:50 It says after 10 months, a thousand mainline commits and a hunt over a hundred contributors.

16:55 We have a new version of micro Python.

16:58 So thank you, Matt, for sending that into us.

17:00 That's a pretty big release, a hundred contributors.

17:03 And so the reason I brought that up is that the GitHub announcement for the release doesn't point out like how big of a release this was like almost a year's worth of work.

17:13 So micro Python, the one that runs on embedded devices, not, not phones, but like incredibly small and cheap devices, you know, like five, $10 chips.

17:22 Yeah.

17:22 It's awesome.

17:23 It's awesome that you can run Python there.

17:26 Right.

17:26 And so micro Python and circuit Python are, you know, similar projects, one fork from the other, I believe, but they've deviated a little bit.

17:35 Circuit Python being more beginner, educational friendly, micro Python being more production device, you know, creating devices to do actual jobs type of friendly.

17:46 But I think they're working a lot together.

17:47 But I think they're working a lot together.

17:47 There's been a lot of merging back.

17:49 So that's, that's pretty cool.

17:50 So this release of micro Python introduces a lightweight package manager called MIP instead of PIP.

17:56 You've got MIP.

17:57 It uses a custom protocol, the query install packages that's optimized for embedded systems.

18:03 So that's pretty cool.

18:04 It's easier to get packages involved.

18:07 It's like if you've done micro Python stuff before, it's not as easy as just pip install this thing.

18:12 It's a little bit, a little bit trickier than that.

18:14 Also, the core runtime and built-in types have been compressed to only including C-level type structs for as much as possible.

18:25 So that's shrunken the size of it.

18:27 Not by a lot, but it's so small that, you know, losing kilobytes actually makes a difference, which is a pretty interesting way to think about it.

18:35 Because we don't worry about the size varying by kilobytes in CPython.

18:38 Right.

18:39 And then there's a bunch of like small changes like Bluetooth low energy changes, SSL settings.

18:46 By the way, SSL is way harder over there than you would imagine it would be.

18:50 There's a bunch of different ports, like the ESP32 is the one that I've worked with.

18:54 And so for each of the different ports that it goes through, there's sort of a summary of like, how has it changed for that one?

19:00 And I'd also like to just remind people, like, while this is awesome for embedded devices, you might think, ah, I don't do, you know, small chip programming.

19:10 So it doesn't matter to me.

19:11 You also might be interested in PyScript, right?

19:14 And so one of the things that they're trying to do is work to get MicroPython to be one of the possible foundations, the runtimes and WebAssembly for PyScript.

19:26 And when this thing is 100K or 75K, whatever it is, all of a sudden you can run PyScript in the browser nearly on par with JavaScript, right?

19:36 Traditional PyScript used the full CPython, at least as much as you can get into WebAssembly, which has meant a 10 meg download.

19:45 And then in the browser, I had to parse and start up that whole thing.

19:48 If that goes to MicroPython, that becomes incredibly fast to download 75K.

19:53 That's like JavaScript size.

19:55 Right. So all these changes are not just like, I don't think, oh, I don't do this embedded device programming, so it's not for me.

20:03 It may well be for all of us soon instead of JavaScript, which is very exciting.

20:08 So there are many changes, like, Ryan, see the scroll bar size as I'm going through this list?

20:13 I am not going to go through them, but if you care, I just want to point out, like, there's a massive new release of MicroPython.

20:19 You can go and see what's changed for the different ports.

20:21 And then in the core, right, like there's just, you know, almost, I don't know how many pages that is, but it's many, many, many pages.

20:28 So check out the linked release notes from the MicroPython team.

20:31 Congrats to them as well.

20:32 Damien George and others.

20:34 Yeah, this is really cool.

20:35 I love to see that basically also that the project is continuing and we all benefit from Python-enabled devices and stuff, and people can invent new things better.

20:47 And yeah, the Internet of Things being in Python is better than having a different language.

20:53 Absolutely.

20:54 Also, just want to, you know, sort of a time travel sort of thing as well.

20:58 I think Matt sent this over quite a while ago, and it's been sort of on our list.

21:02 I finally pulled it off our list and made it a topic.

21:04 So this is from the end of April.

21:06 It's a couple months old, but still, you know, almost a year's worth of work is worth celebrating, even if it's, you know, a couple months later.

21:13 Yeah, pretty cool.

21:15 All right.

21:16 Are we ready for the last, our last topic?

21:19 Yeah, bring it on.

21:20 I wanted to just, so I'm, you know, I shouldn't even qualify this.

21:27 I am, I was going to say I'm not a sucker for listicles, but I kind of am.

21:30 So this is an article called Advanced Python Tips for Development.

21:35 But when I was reading it, so this is by Schofield Idahen.

21:39 And when I was reading it, there's 15 tips, and some of them don't really seem that advanced.

21:45 Like the top one, use list comprehensions.

21:47 Okay, you should do that.

21:49 But there's a few that I wanted to point out that I thought were that I just wanted reminders of to use more often.

21:55 So list comprehensions are awesome.

21:58 And I kind of forget that they aren't obvious to people now because I've been using them for so long.

22:04 So they're great.

22:05 But one of the things, the next step, so tip one is use list comprehensions.

22:09 Tip two is leverage generator expressions for memory efficiency.

22:14 And I don't use generator expressions enough, and I think I should.

22:18 And one of the cool things about this article is it shows side by side a list comprehension and a generator expression.

22:24 And they look identical except for there's brackets versus parentheses.

22:30 So parentheses?

22:31 Yeah, parens.

22:32 And I kind of forget about generator expressions.

22:37 So generator expressions, are list comprehensions not generators?

22:40 I thought they were.

22:42 No, no.

22:43 No.

22:43 Okay.

22:43 Well, the list comprehension executes it all into memory.

22:47 And then the generator one, you have to start iterating through it to create it, which it's cool that they're so similar.

22:55 I'm sure it's caused untold amounts of challenges for people to go, they look the same.

23:03 You can do both.

23:04 It doesn't seem to matter until it really matters, you know?

23:07 Yeah.

23:08 And also, it's not, I mean, when you get used to list comprehensions, generator expressions kind of looks like a tuple expression.

23:16 Yeah.

23:17 Well, and then you put curly braces on it and it becomes a set comprehension.

23:21 Yeah.

23:22 The grant reminded us that.

23:24 Don't forget set comprehensions.

23:25 Yeah, yeah, yeah.

23:27 Okay.

23:28 So let's hop down.

23:29 The enumerate function, this is just take advantage of enumerate function.

23:33 This is just remember to teach people that are coming from C or other for I equals 1 to 10 sort of languages that enumerates around.

23:42 So if you need the index, also use enumerate.

23:45 Don't be a dork and get the length of a list.

23:48 Counter equals 1.

23:50 For I equals 1 to length of a list.

23:52 Yeah, yeah.

23:52 Don't do that.

23:53 Also, enumerate can, if you need it to be a, so enumerate does 0 through whatever.

23:59 If you need it to be 1 through whatever, you can give it a start.

24:03 Enumerate takes a starting point, so you can make it start at 1 if you need it.

24:08 Right.

24:08 If you're working with indexes, the default is good.

24:10 But if you're trying to print thing 1, thing 2, thing 3, then start equals 1 is the way to go.

24:15 Yeah.

24:16 Or if you're using it to get into some other data structure or something.

24:19 Anyway, I'm going to hop down to, so that's true.

24:24 Hop down to 5, which is the zip function.

24:27 And I just, so zip is great for parallel, iterating through parallel lists.

24:33 And you can do more than, this is showing name and age as two different lists and going through them.

24:40 My tip is just practice this several times and unfrequently if you need it.

24:47 Because this was a hard one to pound into my brain, is to remember how zip works.

24:52 Because it's not that confusing, but it's tripped me up for some reason.

24:56 And it's not, so you'll take several lists and it just makes, if you zip them, you end up with a, what is it, a list of tuples?

25:04 Or some sort of iterable, I don't know if it's an actual list, an iterable of tuples that you can pull out different parts of it or something.

25:11 And then you can, in this example, it says for name, last age.

25:15 So that's unpacking it after you get it.

25:18 And it works great.

25:19 I just always forget to use it.

25:21 So a good reminder.

25:22 And then now I'm going to jump down to my 12, one of the things, 12, but 8 is kind of funny because it's a formatting problem.

25:31 But anyway, use counters.

25:32 Counters are good.

25:34 12 is, what is 12?

25:36 Oh, one of the things, 11 is decorate, use decorate, decorate functions with static method and class method.

25:43 I just hardly ever do this.

25:45 Do you use static method or class method that much, Michael?

25:50 Yeah, quite a bit, actually.

25:51 Oh, really?

25:52 Okay.

25:53 Yeah.

25:53 And I guess one of the neat things, yeah, anyway, I just don't use it much.

25:59 Maybe I'll try to explore where I can use it more often.

26:03 The number 12 is use slots to reduce memory usage.

26:07 And I kind of forget to do this, too.

26:10 So this is a good reminder to use slots when you're...

26:13 And this is great, especially if you know ahead of time what, you know, your classes aren't going to add new data as it goes on.

26:22 It's not going to be dynamically generating new fields, yeah.

26:26 And I guess here I just use the adders.

26:29 So anyway.

26:33 Yeah, it's worth pointing out that slots don't just reduce memory.

26:37 They also make attribute access faster.

26:40 So like thing.field, getting and setting that value is also faster with slots.

26:45 Okay.

26:46 Yeah, that is good to remember.

26:49 Anyway, some fun tips.

26:51 14.

26:53 Use pytest.

26:54 It says use unit test or pytest.

26:56 Ignore the first part.

26:57 Use pytest.

26:58 There's a typo there.

27:01 Is that what you're saying?

27:02 There's some typos.

27:03 So use unit test or take out the unit test or.

27:05 And also it says for unit testing, just automated testing, just for all your automated testing, not just unit testing.

27:12 Yeah.

27:12 Well, those are our topics.

27:16 Do you want to talk about some extras, Michael?

27:19 I do have some.

27:21 So I feel like, Brian, it's not time for a joke yet, but there is a pretty good joke on that page we might have to come back to.

27:26 Well, do you want to explore it now?

27:28 Oh, not yet.

27:30 Not yet.

27:30 We can do it later.

27:31 Okay.

27:31 Let's do it later.

27:32 All right.

27:32 So, you know, people have different faces, Brian.

27:36 You know, sometimes you got your sort of like neutral face.

27:39 You got your happy face.

27:40 You got your sad face.

27:41 How about your hugging face?

27:42 What's your hugging face look like?

27:44 So there's this project created by Agustin.

27:49 Let me pull it up here.

27:51 The source code's linked at the bottom.

27:52 By Agustin Pekiris or Agus, as his friends call him.

27:56 Sent in, hey, I was looking to play with the hugging face API.

28:00 And so I'm like, well, what could I work with?

28:02 What if I turn a large language model or semantic search loose on Talk Python to me and their transcripts?

28:10 That's cool, huh?

28:11 Yeah.

28:12 So he created this project.

28:14 You got to go and get a free hugging face API token because it uses hugging face.

28:18 I was joking around.

28:19 But then it says you can ask a question.

28:21 For example, what's my advanced options?

28:23 Oh, yeah.

28:24 I can see how many things I could get back.

28:25 Let's make that 10.

28:27 Focus, folks.

28:28 Come on.

28:28 So you can go things and say, who uses MicroPython in production, for example.

28:35 All right.

28:36 I can type that into the search field.

28:37 And then I can say submit.

28:38 And sometimes it takes a second.

28:40 Sometimes it's pretty quick.

28:41 But we're going to see what we get.

28:42 There's a little running character.

28:44 Although they can't choose their sport.

28:46 It's like rowing and then swimming and then it's running and then it's biking.

28:49 That's what the like on.

28:51 Here we go.

28:51 It's like a decathlon.

28:52 I guess you're right.

28:53 And so here comes the answer back.

28:55 It says over on Talk Python, you should check out PyScript powered by MicroPython.

28:58 And MicroPython plus CircuitPython.

29:01 You might be thinking, well, it's just searching titles.

29:03 But then empowering developers by embedding Python by Nina Zakarenko.

29:07 And then there's a weird one by Brian called 30 Amazing Python Projects and so on.

29:12 Or even the year in review.

29:13 Isn't that cool?

29:13 That is neat.

29:14 So if you want to play with this stuff, either because you want to build a thing like this

29:18 for something else, or you want to just go ask questions about Talk Python, you can go

29:23 and check out this app.

29:25 The source code is linked at the bottom.

29:26 I guess another comment that maybe it's a good idea to have transcripts for people to be

29:34 able to use is search.

29:35 Exactly.

29:37 We didn't have transcripts.

29:39 We weren't able to do this cool project, right?

29:41 So yeah.

29:42 Excellent.

29:42 So that's one.

29:43 And yeah, that's it for me for my extras.

29:46 You got any?

29:46 Yeah.

29:47 One, I just wanted to, I guess, remind people that Python People is a thing.

29:52 Python People is a new podcast.

29:54 And episode three is out with Brett Cannon.

29:57 And one of the quotes from him is, I came for the language, but I stayed for the community.

30:05 We explored that and what was the situation when he talked about that.

30:09 And we talked about a whole bunch of stuff, like what is the meaning of backbaking and toque,

30:15 things like that.

30:16 So check it out.

30:17 Oh, nice.

30:22 I had forgotten to, for people listening, I had forgotten to actually show the episode on the screen.

30:28 I could go back and search Talk Python again for this and see if we find Python people.

30:32 You would find a ton of Brett Cannon over there.

30:34 And we have an episode for him coming up very soon.

30:36 Yeah.

30:36 But no.

30:37 I switched it over to yours.

30:39 Next, I didn't.

30:41 There's a, oh, that's the wrong thing.

30:43 Oh.

30:44 Oh.

30:45 I deleted the thing I wanted to talk about.

30:48 So I guess that's it from extras for me.

30:51 It's gone from the internet.

30:52 It is gone.

30:52 So.

30:53 I'll have a joke for us.

30:56 Okay.

30:57 Well, let's, before we do the joke, we didn't do any sponsors.

31:00 One of the sponsors, of course, is Python people, or it's us.

31:04 But I'd like people to check it out.

31:06 We have like maybe three listeners so far.

31:08 No, it's bigger than that.

31:10 But I'd like it to grow.

31:11 I also wanted to give a shout out to everybody on Patreon.

31:15 So if you go to any of Python Bytes pages, especially ones without any advertising, like

31:22 today's or episode 343, you can see Become a Patreon.

31:27 And you can click on it and become a member and help support the show for a buck.

31:33 That's great.

31:33 I also wanted to give a shout out to all of the amazing courses at Talk Python Training.

31:37 Michael has done a great job.

31:39 Plus, pulling in amazing other people to teach courses like me at Talk Python Training.

31:46 There's some great stuff.

31:47 So check it out.

31:47 Now we can do a joke.

31:49 Yeah, I've got some new courses coming from some really awesome people.

31:53 All right, on to the joke.

31:54 On to the joke.

31:55 So this one is a meme somebody put together.

31:59 I have two jokes here that we can even do the third joke that you had on screen a little

32:04 bit ago.

32:04 So HTMX.

32:06 If you all are familiar with HTMX, if you're not, you should definitely check out our HTMX

32:10 and Flask course.

32:11 This thing is so awesome.

32:13 I had so much fun learning it.

32:14 And I'm like, where is the next project I can use HTMX on?

32:17 Because it's great.

32:18 The idea with HTMX is instead of doing JavaScript, you just write attributes.

32:22 And then that magically through HTMX gets turned into server calls.

32:25 Like if I need to rebuild a table, as somebody interacts with some other part of the page,

32:31 that could just be done on the server and just send little fragments back.

32:35 It's incredible, right?

32:36 So it means you don't have to write JavaScript.

32:37 So the joke is, there's a guy that's back in dev.

32:42 And then this other dude, that's HTMX.

32:45 HTMX says, look at me.

32:46 Look at me back in dev.

32:48 You're full stack now.

32:49 You're full stack.

32:50 Stand up for yourself, man.

32:51 Don't let those.

32:51 Don't feel like you can only write it back in code.

32:54 You're full stack now.

32:55 HTMX.

32:56 Isn't that good?

32:57 Yeah.

32:57 The other joke, before we get to the one that you had on the page, is what is happening to Twitter?

33:04 Did a child try to rebrand this?

33:08 It is so incredibly bad.

33:11 No, it's like branded by a high school band.

33:14 It's so bad.

33:16 Let's call ourselves X.

33:18 That'd be so cool, man.

33:19 Yeah, man.

33:20 And so like, for example, people might be thinking, I go, you're overreacting.

33:24 They tried to take the Twitter logo down and replace it with an X.

33:29 And then the police came and stopped them because they didn't have the Twitter employees doing it.

33:34 Didn't have a permit to drive a crane around downtown San Francisco.

33:38 So it was like half the Twitter logo is like half removed.

33:42 There's no X, nor is there Twitter.

33:44 It says tweet.

33:46 I'm on Twitter.com, but there's an X.

33:48 But, you know, sometimes like, what do you call these?

33:54 Are there supposed to be X's?

33:55 You know, usually X's is kind of a bad.

33:59 I mean, it's just like.

33:59 And if you share another one, is it a re-X?

34:02 Yes, exactly.

34:04 And there's some random person who has X as a handle on Twitter.

34:09 And they're like, what's going on?

34:11 Am I going to be like Twitter?

34:12 I heard that they don't, I don't know for sure on this one, but they don't seem to have

34:18 the intellectual property rights to like trademark the letter X.

34:23 Well, you can't.

34:24 I know.

34:25 And this X looks like, I think the X11 logo.

34:30 If you go look at that, I think that was the one.

34:33 It's like, it's like a thick right slanty versus a thin left slanty, which is, you know, one's

34:41 hollow, one's solid.

34:43 Other than that, they're kind of.

34:44 Anyway, there's.

34:45 Well, that's sort of a meta joke.

34:47 On the good side, current employees and those that are laid off are all X employees now.

34:53 Exactly.

34:54 Look at all the people that work for Twitter now.

34:56 They're all X employees.

34:58 All right.

35:00 So that was just because this came from Twitter.

35:02 I'm going to open up like, wow.

35:03 This is getting.

35:04 This is getting janky.

35:05 It's X news.

35:05 So it has to be part of our extras.

35:07 It absolutely does.

35:09 All right.

35:09 Do you want to just give a quick shout out to what was on that page before?

35:13 So what were you referring to?

35:14 The only valid measurement of code quality.

35:17 Oh, yeah.

35:18 The WTFs per minute.

35:19 Okay.

35:19 Yeah.

35:20 WTFs per minute.

35:21 It's true.

35:22 Oh, that's the.

35:23 Yeah.

35:23 You need the full one.

35:24 Oh, wow.

35:25 You lost it now.

35:25 That was an ad.

35:26 It was an ad.

35:27 Yeah.

35:27 It was a code review.

35:29 And behind the door, you could just hear WTF.

35:31 What WTF?

35:32 And the good code only had a couple.

35:35 The bad code was just like overwhelmed with them.

35:38 That was the joke.

35:39 Yeah.

35:40 All right.

35:40 Well, this episode was no joke.

35:41 It was a lot of fun.

35:42 Thanks, Brian.

35:43 Thank you.

35:43 And thanks, everybody, for showing up at a weird time.

35:46 I really appreciate it.

35:47 It's great.

35:48 So.

35:49 Yeah.

35:49 See you later.

Back to show page