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


Transcript #354: Python 3.12 is Coming!

Return to episode page view on github
Recorded on Tuesday, Sep 26, 2023.

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

00:05 your earbuds. This is episode 354, recorded September 26th, 2023. I'm Michael Kennedy.

00:13 And I'm Brian Okken. I am good. It's been a busy week and it's only Tuesday.

00:18 I know. And it's starting strong. If you want to follow the show, stay in touch with us.

00:23 Be sure to check out Bastodon over on Mastodon. We got all the links for that in the show notes.

00:29 I was just thinking today, I just booked a couple of episodes through Mastodon for Talk Python. I just

00:36 was working on another video presentation thing on Mastodon. How much work gets actually done on

00:43 Mastodon. So people should be there with us, Brian. Yeah, I think so. Yeah, for sure. For sure. It's

00:48 the place where all the cool kids are. Indeed. Indeed. So hopefully you'll connect with us over

00:53 there as well. Very exciting stuff. See some people in the audience here. I'm going to have to give

00:58 them a shout out later because some things that we're sharing. And so that's going to be very

01:03 exciting. So speaking of exciting, what's the first thing you got for us?

01:07 I'm actually really excited. I may be jumping the gun on this, but Log Merger is from Paul Maguire. And it's a project that he's working on. And it's pretty fun. It's so I don't know. Maybe I'm not. I think more people, a lot of people deal with log files that they have to deal with more than one. So you have maybe two processes or three that are all timestamping and saving. Well, so this is a project that is

01:36 is a textual based project, but it combines them all and sorts the multiple logs based on timestamp. So you've got to see you've got maybe you've got a timestamp and then content and it splits it out and in and shows you the timestamp on the left and then the different log files in columns.

01:59 And the example just shows two, but I think you can pass it more than more than two. I think you can do multiples. So it's, it's called log merger, but it's not. It doesn't. I don't know if it actually merges them, but it makes this combined output thing. And it's really kind of fun.

02:14 It's more look at them in a merge, what a merge view with timestamps would look like rather than actually. Yeah. About trying to unify them or something. Huh? And I had some concerns right away and they were already like, I, I downloaded it and I'm trying this out. the, you can pipe the output to standard output, or you can use the textual thing. So you can do either one. so the output is nice, but sometimes, you know, log files can be huge.

02:39 And you only want to look at a part of it. So there's a cool, there's some, some nice flags that they're included. There's a start and end timestamp. So where you can say, yeah, start here and then go to here and don't do the rest of it. there's an interactive mode, which is, I think the default. Yeah. That, that shows you the little two and you can do error boxes and stuff. you can save them to a CSV. I don't, I think that'd be great if you want to throw it in Excel or something like that. and then multiple timestamp formats are

03:09 supported. So, so you've got like, there's a handful that I think this is pretty good. This is the standard ones. I didn't even pass in a timestamp when I tried it out and it just worked fine. so I'm going to be using this a lot. The, the, because I'm excited about some of the upcoming work. So there's, possibly, oh, maybe it's not here, but somewhere else. there's a possibility of using PCAP files. I think that's in working on those are, I don't know.

03:39 or even remember what that stands for, but I deal with them for protocol, analysis. but the, the, I maybe jumped the gun because you can't pip install it yet. You have to right now you download the code, but it's totally usable and runnable. so I, I think it's worth checking out, but it's, oh gosh, it's new. It's like,

03:58 you probably could pip install with the get. Oh yeah. With the get plus exactly. Yeah. With the get plus.

04:04 Exactly. I forgot about that. So you can do, yeah. So, I guess, Paul, people are using this.

04:12 At least I am already. So maybe like a little, maybe I'll do a merge request to add the read me to say

04:17 how to install it for now. So cool. Fun. Yeah. Nice. And prior guest on the show,

04:23 Michael Larson says, whoa, packet capture files. Is that the accentuating for it? That's awesome.

04:28 I'm going to need to check that out. Yeah. And Jeff out in the audience says, does it support time zones?

04:34 It does have a time zone display feature, but I don't know if the sort considers time zones or not.

04:41 Well, it might, my thing is going to be that they're going to be a little off anyway, because

04:47 sometimes the, the different, I've got log files getting generated by multiple computers that are,

04:53 the timestamps off by a little bit. but yeah, it's close. It's usually close enough to line

04:58 them up. Yeah. So close enough. Yeah. I do stuff like this as well. Like for all the talk Python

05:04 web properties. you get lots of requests and the engine X files have like a two week rolling

05:11 average. The most recent one is a straight log file, but the rest are G zipped by day.

05:18 Okay. So I have a Python script that downloads all of those unzips. The ones that are zipped,

05:25 puts them all together, then loads all of those files, sorts them by timestamp, and then like

05:29 creates one super log file, maybe a pending onto a previous one. So I have like single log text log

05:36 files that are the full month, month by month for analytics. Cause you know, we turned off Google

05:41 analytics and all sorts of other things because those are evil. Yeah. But you still want to know

05:45 like, well, how many requests were there to this page or to this episode page or like where, you know,

05:51 stuff like that, right. Those, those kinds of things are relevant. So yeah, this is, this looks

05:56 interesting. I had to write a bunch of code to do similar stuff. Although for 14 log files, you wouldn't

06:01 try to visualize them. You want to, I just want to turn them into one mega log file so that I can run

06:08 analytics across them. It's not on this read me, but I think when I was looking at it, I think there's,

06:13 there's recent stuff being done and I think that you can pass it GZIP files. I think it pulls them

06:18 out. It seems reasonable. Those are, frequent formats, I suppose. Anyway. All right. Cool. Good

06:24 find. Very interesting one. People in the audience like it as well. This next one comes to us from

06:29 Hugo VK and not, not sent in. I just discovered it, I believe it's hello. Python main library maintainers.

06:36 So if you have a PI PI thing, if you twine or what upload those types of things,

06:42 you probably want to pay attention because I said, because everyone was so good at finding

06:47 bugs last time in the Python 3.11 release candidate, the third and final release candidate is now out.

06:55 Please give it a spin. It's your last chance to find, significant problems, right? Critical

07:01 problems. And goes on to point out, here is a nice article on how to test it, how you can get the

07:07 release candidate. And basically how do you test your libraries with this? And it goes through like,

07:12 how do you set up a GitHub action so that it will use the 3.12 free release, right? Yeah. how do you do

07:19 it from dead snakes? How do you do it for Travis CI or other CIs and different things in here? So that's cool.

07:25 That'll help some people set it up into their CI. There's also a big long discussion here. So Thomas

07:31 orders, points out that at least candidate three is here as a reminder until it's, until the final

07:37 release of 3.12, zero, the release 3.12 branches set up. So the release manager has to merge to the changes,

07:44 right? So reach out at this point, unless something critical comes up, it should really only be

07:49 documentation. Other changes will be pushed to 3.12.1 and somewhere in here, there is, yeah, the intent.

07:57 This is exciting. The intent is for the final release of 3.12.0 scheduled for Monday, October 2nd. That is

08:05 like the coming Monday. Yeah. Unless you, if you're on top of your Python bytes playlist, don't let that thing

08:11 fall behind. Then the coming Monday, you know, October 2nd is going to be when this thing releases. So that's

08:17 pretty excellent. I guess bringing back to the first part, this is basically you have a couple days to make sure

08:23 that your library will have no hiccups when Python 3.11 ships. So, or C3.12 kind of gets used to saying 3.12.

08:31 When that ships, in a week, you want to make sure that your stuff just works. So here's your chance and a few steps on

08:37 how to do that. Yeah. Because you know how nice people are in GitHub. You'll get issues right away.

08:43 Hey, your stuff doesn't work on 3.12. You might even get like some hot October amazingness. Like,

08:51 Hey, you were using the wrong preposition here. I changed it. Like, well, that was not wrong,

08:55 but this is not a real commit. Yeah. Seth is back to say, highly recommend the setup. Python allow pre-releases

09:01 feature that lets you set up a forever pre-release testing job. If you use a Python version 3.x,

09:09 that's pretty, pretty good advice there. Yeah. Cool.

09:11 Neat. I don't think I use that. I'll also check it out.

09:14 Well, now, now, you know, you can.

09:16 Yeah. All right. All right. What else do you got as exciting for us?

09:19 Okay.

09:19 What other good advice do you have?

09:20 what do I got? I got, oh, good advice. I think I have questionable advice.

09:28 but I like this pattern. So I I'm, linking to, James coffee blog with, the Python dictionary dispatch pattern. And I just like this cause I don't know if it's not discussed

09:41 much in like beginning teaching Python stuff is to, but, you know, if you're a C programmer,

09:46 use jump tables or maybe you shouldn't use jump tables, but jump tables are fun and C, and you can

09:52 kind of use them in Python too, but they're, they're a little bit, easier to use. Yeah. I just have,

09:58 dictionaries, that dictionaries can store anything and they can include functions. So,

10:04 he has an example of just add, subtract, and multiply, which you wouldn't really use for that, but

10:08 it's just an example. And I kind of forget that you can throw lambdas in because you can assign the

10:14 lambdas have a value. So you can put a lambda in as a function, but, you can use, use a,

10:20 use a function also, and just, just, then you can call them later. So you could just, dereference the,

10:26 or dereference, we don't call it like that. You look up the key, the element, in the dictionary,

10:32 and then actually just call it with parameters and it works. So, kind of a fun thing to do in

10:37 Python. he has a little bit of a, he said, as part of a vision script programming languages,

10:45 does that. interesting, but I mean, there's, there's a lot, there are times where you, you just

10:50 have lots of things that you're switching on and an easy way to do the switch is just to have a

10:56 dictionary lookup. So. Yeah, exactly. That's, it is pretty interesting. it's a traditionally,

11:01 it has been a way to do switch statements, which at the time it was pretty much all you had to work with.

11:09 Right. Since then we've had the match statement added to the language, right? Which is a little bit

11:15 better. So not switch, but match because it's this whole Arzor mechanism on top of just the switch

11:21 statement. But people used to traditionally say, okay, well, we'll just make a dictionary. And then

11:25 like your case is the key. And then what you do is the function that gets returned from that.

11:30 one thing that's really missing from that pattern, that dictionary dispatch pattern is that the default

11:37 case gets clunky looking, right? Like if, if none of the cases match, then what happens? Like you just

11:43 get none and exception, like none type is not callable or some weird thing like that. Right. Oh yeah, you do.

11:49 Yeah. So you could, you could upgrade it. You could upgrade it with a default dict where the default dict

11:54 returns the default case. Right. I, for a while, I don't remember when I added this, but I added

12:01 switch laying, which was fun and switch laying, uses context managers to simulate a switch with a default

12:08 case sort of thing. Yeah. Or, but Seth is pointing out, get, if you use get instead of a

12:15 dictionary lookup, you, you can have, give it a default to return. You can, but you got to give

12:20 it the default every, yeah, but you got to give it the default every time you use it, which is kind of

12:24 you can, but it is a little bit weird, right? Like that's why the default dict makes it a little

12:29 clear. Cause if you're going to use it more than one, I don't know. You use it more than once. It gets

12:32 janky. Right. So I, but so I've used this and I, I don't use, I don't put a fall through, but what I,

12:39 the reason is because it's all my code. It's all, I don't, it, it isn't something that's,

12:44 that's coming in from the outside world. It it's, and I have test cases around all paths. So,

12:50 right. So, you know, there's not going to be a missing case. Yeah. If you do an exception is

12:54 probably a good idea. It's not something you like, ask a user, which function would you like to call?

12:59 And then, you know, pass it through. it's a lead. Yeah. Don't do that. Anyway. I, I, oh,

13:05 I reason why I wanted to bring it up. Not is because I, not, I didn't want to bring this up because I wanted more

13:11 people to use a dictionary dispatch. you don't have to do that. What I brought it up for,

13:15 which is, it's still kind of cool to reference just to let people know you can do it. But,

13:20 this guy's got a blog role. How cool is that? when's the last time you seen a blog, a blog role?

13:26 Yes. Should we bring blog roles back? I don't know. Maybe, maybe, I don't know.

13:34 Anyway, that was when your blog was your little home on the internet. Yeah. Yeah. Yeah. How

13:39 interesting. Oh, there's no like, hit counter though. So, you know, Oh, does it have a

13:45 little dig? Like a little digging? This part is under construction digger. That'd be cool. No,

13:50 sorry, James, if you're listening, we're not dissing you. It's just fun. No, no, no. It's also,

13:54 it's nostalgia is what it is. Yeah, it is.

13:56 So anyway, all right, back, back to the, Seth Michael Larson show. Yeah. So

14:04 his, his article is very timely that he just put out, a little couple of weeks ago, but I'm

14:12 finally got around to featuring it now, given everything that's coming together called visualizing

14:16 the CPython release process. So it was awesome. He's the, Python security manager, security dev,

14:26 as opposed to Mike Fiedler, who is the pipe PI one. Both of these roles are somewhat new,

14:32 which are awesome. Right. This one is made possible by funding from open SSF alpha mega projects. So

14:38 very, very cool. And Michael or Seth is pointing out security developer in residence is the official

14:44 title. Yes. Right. Right there. and then we also have the developer in residence, which is

14:49 Lucas Lange. So anyway, they, they planned out or he went down and wrote out what it actually looks like

14:55 to release Python and boil boy. This is more than just, some build CI at GitHub to make sure that

15:02 the wheels or the binaries get built. So here's the process, see how close I can get this right. And

15:08 also, Seth is going to be on talk Python on Thursday in terms of live stream. And then a little

15:14 bit later to talk about, we'll talk about this and a bunch of other security things anyway. So start out,

15:20 freeze the release branch. And then the CPython upstream repo, goes along and the release

15:28 manager forks, the repo takes that feeds it into the release tool manually. All these things have,

15:35 there's a bunch of colors in this diagram. So each, each color, there's a legend like, the hand

15:40 ones are human tasks. The blue ones are release artifacts. Interesting from a security perspective.

15:46 there's a source of risk is red and so on. All right. So the release tool goes along and get commit,

15:53 get tags things to, set the tag to version, you know, 3.12.0. Also it creates the source ball,

16:01 the tar balls from that. And where do we go now? We go over here to Azure pipelines for the windows

16:07 people, the Azure pipeline. There's a windows release manager, the Azure pipeline over there

16:13 builds out the windows embeddable packages of windows installers updates, new get windows store,

16:18 maybe even when get, I don't know about that. there's also an equivalent for the macOS release

16:23 manager who does the Mac build and Mac installer. And all of these things come back into testing artifacts

16:30 and creates the, they all get a GPG signature. And then we get everything signed and ready to go.

16:37 That gets dropped on python.org. Pretty cool. Huh? That is. Wow. Yeah. It's a lot. Last year,

16:44 they live streamed this and all the people involved were on zoom. I think it was, I'm not sure. It was

16:50 live stream to YouTube though. And you could actually see step by step. So, but I don't know how well people

16:56 really knew what was happening. Oh, you can be like, all right, we're on step five, everyone.

17:00 Let's go. Let's go. So I think, you know, if you're going to watch that live stream, if it exists,

17:04 I'm not sure it does. people in the audience, if they know it's going to be live streamed,

17:08 shoot out a message. yeah. Okay. So it's too early to, I don't want to slow down to the release

17:14 this year, but maybe next year we could have this graph, but like animated with like little,

17:19 little things, what's going on. Yeah. Have like little, little, video cutouts of people on the

17:25 different sections and they're talking and yeah, it'd be fun. Why not? Why not? No, this is cool.

17:30 And then there's more about, there's like a more of a description below that Seth put together

17:34 as well as the sources of supply chain risk and examples of that happening outside of Python

17:40 primarily. so pretty cool. thanks for the, the visualization, Seth, this is great.

17:46 Yeah. This is cool. Nice. Yep. Over to you. no, wait, that's it for, I'll read for extras.

17:52 We are in extras. Do you want to do your extras first or? Yeah, sure. They're easy. I'm going to

17:57 be at pie Bay over in San Francisco, October 8th. So all I want to say is if you're around,

18:03 come say hi. Right. That's like primarily the reason that I go to conferences. I don't go to that

18:08 many talks or that many other things, but these kind of like get to know people in open spaces and so on.

18:13 So this is all one giant open space. This, pie Bay thing. Yeah. I went last year. It was fun.

18:19 Maybe we should just bounce back and forth and do every other. Yeah, absolutely. the

18:23 HTMX plus Django course is going really well. People are loving it. So if you want to do HTMX

18:30 with your Django code, it will make it so much better. Like you don't have to do front end frameworks

18:35 unless you really, really want to. so HTMX is awesome. This is how I use it with Django. Each

18:40 framework has its kind of own thing. The reason I bring this up is we're closing in at the end of

18:45 the early bird discount. So if you would think you're going to get it anyway, you've got until

18:49 September 29th until, the price goes up. A few more days. So check that out. Yeah. That's it for my

18:55 extras. Nice. I'll try to go through mine a little quickly. Anyway, of course the complete

19:03 pytest course, I up did just updated, part three is started. It's, not part three,

19:10 part two. I've started with chapter seven, testing strategy. So that's going along strong.

19:15 I wanted to, mention some podcast names. so of course you're here with Python bytes,

19:22 that's us and my other one, a couple others, Python people, is, I've got a lot of great

19:30 interviews coming up. and then testing code is now Python tests. So you get the, just here,

19:35 we have Python bytes, Python people and Python tests. And then now talk Python to me is the odd man out.

19:41 So we have to get my, you got to change your name to Python talk. Python talk. Yeah. Python talk.

19:46 Yeah. Anyway, I could do that. I could change it. I can change whatever I want.

19:51 No, no, it's, it's working great. Don't change it. If it's not broken, don't fix it.

19:55 No, it's going, no, it's going pretty good. Speaking of broken, let's talk about the final thing,

20:00 a joke here. Okay. Maybe this has happened to you. Here's a, a woman developer trying to sleep,

20:06 but her mind is running and she's like, okay, mine, stop. I need to sleep. Leave me alone.

20:12 There's like a little conversation, brain woman in bed, right?

20:16 Says, Hey, are you sleeping? Yes. Now shut up. She says to her brain, the brain says, I know how to fix the bug on line 255. Boom. Eyes wide open. No more sleep.

20:25 I can't sleep. We probably all been there, right? You're just like somewhere else. I know what it is.

20:32 I know what it is. Yeah. So that's one of the database index. No, it's one of the downsides,

20:37 but also one of the upsides of working being, having a setup for working from home so that you can just

20:43 run in and actually fix it and then go back to sleep. Right.

20:46 Or you can sleep at your desk. And then when this happens, you just wake back up and keep typing.

20:49 Okay. There we go. Yeah. Awesome. Well, I mean, I have a standing desk. Why not a,

20:58 like a sleeping desk though? Why? Yeah. Why? You know, it goes, they go from sitting to standing.

21:03 And it could just go one more level and you're like a lazy boy just drops you into like sleeping

21:08 position. Yeah. With a lazy boy. That'd be awesome.

21:09 White noise kicks in as it gets below a certain height. Yeah. Monitor goes up to the ceiling.

21:14 Exactly. Yeah. Be good. Anyway. All right. well, awesome podcast again, Michael. Yeah. Thank you.

21:21 Thank you as always. And thanks everyone for listening and some of you for attending.

Back to show page