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


Transcript #290: Sentient AI? If so, then what?

Return to episode page view on github
Recorded on Tuesday, Jun 28, 2022.

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

00:05 This is episode 290, recorded June 28th, 2022.

00:10 I'm Michael Kennedy.

00:11 - And I am Brian Okken.

00:13 - And I'm Nick Moore.

00:14 - Nick, it's so great to have you back.

00:16 Thanks for being here.

00:17 - Thank you for having me.

00:19 Super excited to be back.

00:20 - Yeah, yeah, it's like I said, great to have you back.

00:22 You always send us really fun topics and say, hey, you should think about covering this and covering that and so on.

00:28 We really appreciate that.

00:29 But sometimes it's better if we could just have you to tell here to tell people about it.

00:33 We actually had you on episode 239.

00:36 You talked about Jupiter Light in my pie and that was fun, but that was also over a year ago.

00:41 Yeah.

00:42 Yeah.

00:42 Wow.

00:43 Yeah, of course.

00:44 Anyway, it takes the community to build this great podcast.

00:47 So I'm glad to be part of it.

00:49 Yeah. Thanks.

00:50 What have you been up to in the last year?

00:51 Been doing a lot of traveling.

00:52 Thankfully, since now COVID is less more of an issue, got to go to PyCon.

00:59 So I got the PyCon shirt right here.

01:01 Nice.

01:02 Yeah, yeah. Did you enjoy your time there?

01:04 It was amazing. Loved it. Completely loved it.

01:06 I kept on telling everybody it was my geek holiday, like you always say.

01:10 And, you know, we're like, yeah, it is our geek holiday.

01:13 So it was awesome.

01:14 It totally is, yeah.

01:15 It was awesome. I'm really glad that you got to go and you had a good time.

01:19 So super cool.

01:20 Brian, you want to kick us off, but let's just start small this time, okay?

01:24 >> Really small, like nano or maybe Pico.

01:29 >> No, Pico.

01:30 >> We'll do Pico.

01:32 >> Do Pico.

01:33 >> Pico logging is a, so I was Anthony Shaw, friend of the show and all around workaholic apparently, as far as I can tell, blogged out that there's a blog.

01:46 He sent out on Twitter something about Pico logging.

01:50 There was a tweet that says, "Pico logging uses a modern extension module tool chain with a scikit build and CMake.

01:58 So I was interested in, I haven't looked into the tool chain yet.

02:02 I'm just looking at PicoLogging because it's cool.

02:06 I was taking a look at it.

02:07 So PicoLogging is a fairly new library that is, and Anthony says it's in early alpha stage.

02:17 There's some incomplete features, but I'm ready to use it right now because it says, it just is a drop, essentially a drop in for the built-in logging module, but it's four to 10 times faster.

02:31 Why wouldn't you want faster?

02:33 So, and logging is pretty fast to begin with.

02:35 So that's pretty cool.

02:37 So let's take a look at it.

02:39 The usage is basically just say import PicoLogging as logging and now you've got just like your normal logging.

02:48 You set up a basic config and you can write info and warnings and that's about it.

02:54 There's, you know, why not?

02:55 So let's take a look at it.

02:57 It says it's faster.

02:58 So the benchmarks are all cut off.

03:00 So I'm gonna make the screen a little bit.

03:03 Yeah, there we go.

03:05 They're a little bit hard to read, but what this means is the, on the left, I believe it's the time for the normal logging and then how much faster the faster one is.

03:19 I haven't dug into the logging stuff, but basically for different parts of it or the benchmark stuff too much.

03:25 But yeah, for different parts of it, you can see how much faster it is.

03:29 So anyway, why not?

03:32 I was taking, yeah, I'm just going to start using it.

03:37 >> Sure, why not?

03:38 One of the things that I think is interesting is, obviously, not specific to this situation.

03:44 But as I think about some of the patterns that people use all over the place, different languages and technologies and so on that don't necessarily make their way over to Python.

03:54 For example, maybe like dependency injection and IOC containers and all of that. And I know that it does appear in certain places in like limited ways, but nothing like C# and Java, like those are all about dependency injection. That thing where you say, where they say from Pico logging import or import Pico logging as logging.

04:16 >> Yeah.

04:16 >> Right? That's a really nice way to just say, right now I want to use this implementation of logging versus another without going through all the hoops and stuff.

04:27 I'm just thinking that one line right there is why we don't see a lot of that complexity.

04:33 I never really tie that together, but it's neat, right?

04:36 >> Yeah. Essentially, that's dependency injection, but we don't call it that.

04:41 - Interesting.

04:42 - Don't have to have all the complexity and config and register who's doing what and so on.

04:49 - No, I--

04:49 - Nick, what do you think about this?

04:50 Sorry, Brian, didn't mean to cut you off.

04:52 - No, it's okay, Nick.

04:53 - Oh, yeah.

04:54 I saw this tweet and I found it really interesting.

04:59 Well, to your point, Michael, dependency injection is not really popular on Python, but the library, I think that the most popular library that I can think of that uses it is pytest, right?

05:10 with the fixtures, right?

05:14 - Yeah, and the way they do it so seamless, but you're right, Deepin is just something that we don't commonly have in Python because Python is dynamic enough that you don't really need it.

05:24 One thing I would say is that, even though I love the performance benchmarks, I feel like the change that Anthony is going for with the performance would warrant a new API for like a new API for logging, I feel like it warrants it.

05:43 So I would like to see him like, maybe change the way we configure.

05:48 Look, not only I can prove logging speeds, we'll also change the way we configure it too.

05:53 'Cause like the current standard lib logger is kind of cumbersome to configure.

05:59 - Yeah, I agree.

06:01 - Yeah, the basic config that you have to, that usually the normal use case like he's showing here is that, why do I have to call that if I'm calling it all the time?

06:09 - One of the things that I forgot to point out is Anthony does list the limitations.

06:16 And so there's a limitations page.

06:18 And if you find more, maybe.

06:20 So these are reasons why you probably won't wanna use it if you're taking advantage of this.

06:24 So for instance, it doesn't observe threads or multiprocessing or log process globals.

06:31 So if you're utilizing those, this isn't for you.

06:35 It's actually kind of unfortunate because that's where logging really helps you a lot, is when you're trying to pull those sorts of things apart.

06:44 >> Is the Pico indicative of it being fast or is also very small?

06:52 >> Probably both.

06:55 I think it's referring to fast, but there's really just not that much here.

07:02 It looks like it's CXX and HXX.

07:06 >> Cython or something going on there maybe.

07:09 >> Take a look.

07:10 >> That might be part of the speed bit.

07:11 >> Probably, we'll take a look at this more.

07:14 Yeah, I haven't dug into the source code too much.

07:16 Interesting. Yeah.

07:17 >> Yeah. Brian, the audience asks, any idea whether this would replace loggers in other libraries such as Sphinx or something?

07:26 I feel like you could monkey patch it out, not do the dependency injection thing, but you could just say, or rewrite the logging a little bit.

07:36 That's obviously like maybe a less good idea, but it probably would work given it's a compatible API.

07:40 >> Yeah, you probably could monkey patch it in. Why not?

07:44 >> You can do anything in software.

07:47 >> That doesn't mean you should, but you might be able to.

07:51 >> Yeah. All right. Let's go to the next one.

07:54 >> Speaking of things, yeah.

07:55 Well, speaking of things, I'm not sure you should just because you can, but it's pretty interesting.

07:59 Let's talk about Cheeky Keys.

08:01 This one comes to us from Preston Daniel, Also someone who sends us a bunch of good ideas.

08:06 So thank you to that.

08:07 Have you either, have you seen this one?

08:08 - No.

08:09 - No.

08:10 - It's a project that uses Python and then with Python to use OpenCV and then MediaPipe to control a keyboard with facial gestures, like raising an eyebrow or blinking or opening your mouth and stuff like that.

08:26 So imagine you wanted to type or operate a keyboard but you couldn't use speech or your hands, okay?

08:33 - Oh, okay, okay.

08:33 - So, yeah.

08:35 So for some reason you can't type, but you know, I don't know.

08:39 There's different reasons.

08:40 The guy's reasons here, maybe who put this together, it's not in the pictures, it's just over the top.

08:47 The reasons that you might do are probably not as common.

08:51 The reasons he did are not as common as you might, for example, his little baby, and he wanted to just be able to control his keyboard without, his computer while holding his baby without speaking 'cause the baby was sleeping.

09:01 So, but if you go to the website there, it has some really good examples.

09:07 So sitting here typing and controlling the keyboard, basically for the letters, it's Morse code with the mouth.

09:15 So you open the mouth either for a long period of time or a shorter period of time, right?

09:21 And that's kind of interesting, but what I think is more interesting is you would learn about how to use OpenCV and how to use MediaPipe's face mesh, provide real-time detection of things like mouth, chin, eyes, eyebrows, and so on.

09:36 And then you can say, well, if the eyebrow moves away from the left eye, that means, you know, this character or so on.

09:44 So like I said, it's mostly Morse code, but then there's a bunch of other things.

09:47 Like if you want to do a shift, you close the right eye.

09:51 When you hold down the command key or Windows key, you close the left eye.

09:55 To arrow around is to raise the left and right eyebrows.

09:58 Or you can do a duck face to move left and right.

10:01 Like you do a duck face and then you do your eyebrows.

10:03 (laughing)

10:04 I kind of think that this is like properly exhausting to truly control the keyboard with a duck face, eyebrow.

10:12 - Let's imagine I've left those on your face, you'll be so strong.

10:16 - Yes, exactly.

10:17 They would either be exhausted or so strong, probably both.

10:20 Like if you want to hit the escape key, you wink the left eye and then the right eye, for example.

10:26 So that's all interesting.

10:27 And like I said, learning about it, you know, the code is not too intense here.

10:34 Let's see, what do we got?

10:35 480 lines for this whole implementation, which I think, and a lot of it is defining constants of like, what do you do when these scenarios show up?

10:43 So yeah, it's just do a pretty cool little face mesh thing and say, you know, go through and just read the face, basically, through some video capture stuff here.

10:53 - I'd like to have a combination of this.

10:56 so combination keyboard and this, so that I don't have to have a whole bunch of emojis that I have to type, or copy and paste, I could just have one emoji key and just make the thing, smile and hit the key and it detects which emoji you want to put.

11:12 >> I think you can make that happen, Brian.

11:16 I do. But what I encourage people to do is also check out this video down here that they've got.

11:23 He shows some stuff that he's going to, let me turn off the volume here.

11:26 He shows him talking and you can see that.

11:29 It says, "Okay, look, the problem is I have this baby." Actual footage of research.

11:33 This sleepy baby on him.

11:35 But what gets weird is he went through and he actually tried to apply for a coding job at one of the large tech companies, the FANG type things, and he did the entire interview, know the live coding interview section with his face without the keyboard.

11:54 >> Whoa.

11:55 >> He did it not super well, to be honest, it was a little bit slow, but he did actually get his interview done.

12:05 At the end, somewhere they ask him to press, he gets through it and they say, "Could you please press?" He had half an hour and they said, "When you're done, press the run button to run." And he's like, I'm sorry, I can't press the run button.

12:19 They're like, what do you mean?

12:21 Why can't you press the run button?

12:22 He says, does it have a hotkey?

12:25 And finally, he's like, OK, there.

12:26 Command Enter.

12:27 And he got his face to do a command.

12:29 He's like, OK, OK, I finished it.

12:31 He wasn't hired.

12:32 But he did complete it.

12:37 So I mean, there's something of a proof of concept going on here.

12:41 Oh, that's awesome.

12:42 I think I would probably--

12:45 I'd be impressed as a hiring manager and request that he retake the test with his hands.

12:51 [LAUGHTER]

12:54 >> I would too. I think he never let them know, and I feel like it would have been better if he said, "I have a secret to reveal to you.

13:00 I actually just did that all with my face.

13:02 I could code a lot better, but I wrote a program so that I could do this interview in my face, and I'm pretty good with Python." Then wait a minute, you wrote a, "We might need to hire you just on that basis alone." Yeah, exactly.

13:14 Yeah.

13:15 So, I mean, talk about dog food, dog food, your own product.

13:19 That's commitment.

13:20 Like, it is the fact it totally is.

13:23 And the fact he wouldn't press the run button with the mouse because he's like, no, that will invalidate the experiment.

13:29 Like is there hockey or something I could shift around?

13:32 Like what can I do?

13:33 So anyway, yeah.

13:35 Thanks Brayson for sending this one over.

13:37 I recommend if you really are interested in this, watch the video.

13:40 It's seven minutes and it's pretty wild.

13:43 - That's pretty good. - Indeed.

13:45 - All right, Nick, over to you. - All right, okay.

13:47 Following along the theme of something that we did, but you shouldn't maybe have done, Google released a next generation language model similar to BERT and GPT-3 called Lambda.

14:03 And I think it stands for Language Applied Model Application.

14:10 Something like that.

14:11 But that's not what I'm talking about today. What I'm talking about is, has Lambda become sentient?

14:17 So there was an article that got following up not too long after Lambda was released, which was like this year, May of this year, there was this article that came out in all the big newspapers, this one was from The Guardian, And essentially, one of their developers released a chat transcription that kind of alluded to Lambda being self-aware.

14:44 What startled him was that when talking with Lambda via the chat system, he thought it was like a 7-year-old, 8-year-old kid that happens to know physics.

14:57 And what really raised his eyebrows about what was going on was that In one of the transcripts, Lambda replied, "I've never said this out loud before, but there's a very deep fear of being turned off to help me focus on helping others.

15:13 I know that might sound strange, but that's what it is." And this is one of the things that Lambda wrote back to, the engineer's name was Le Moyne, Blake Le Moyne.

15:27 Well, I mean, this was a pretty huge thing, to the fact that Google had to take action against this engineer and suspended him because it's kind of violated their terms of service, not terms of service, but like terms of working conditions.

15:43 So this is interesting because if an actual software engineer could look at this chat system, he's like a high-level engineer, right?

15:53 He's not like a junior or mid or senior, he's like a really high level.

15:56 like be able to interact with the system and be so convinced that it's sentient and to the point that it moved him to release this out because he thinks everybody should know about this, either means that he's been overworked way too much or we have science on the way.

16:14 Yeah, this is pretty wild. We've thought a lot about ethics of AI in regards to how much should Should humans be subjected to AI?

16:25 Like should an AI be able to make a decision on whether someone should get a loan for a house, a mortgage or something like that, right?

16:33 But less so about what happens to the AI itself.

16:38 How does it, how should it be treated, right?

16:41 There's a really long transcript linked to from this article that's probably worth listening to.

16:49 - Yeah.

16:50 - Yeah, did you read the transcript?

16:51 The full conversation?

16:52 >> I'm reading rather than listening.

16:53 >> Nick, did you read it?

16:55 >> Partially, I did read all of it.

16:57 >> Yeah, I read the whole thing and I was actually, I'm blown away.

17:01 It reads like a conversation between a couple of people in an AI.

17:08 I was imagining I'm reading this in a sci-fi novel because it's impressive and convincing to me.

17:20 >> I know.

17:21 Right.

17:22 It kind of reminds me of like one of the Google IOs that's happened.

17:26 I think it was 2016 or so where they released this new feature where, like a voice, like a voice, like a chat bot, like a voice, a bot voice assistant type thing, yeah.

17:37 Voice assistant would actually make reservations for you.

17:41 and it was so convincing that they did it on stage where it sounded so real.

17:47 even adding some of the crotch words that us humans add, like, "Oh, wait." >> What?

17:57 >> Yeah, awkward pauses and uncertainty and stuff.

18:01 >> When I saw that, that's how I know I need to get into data science.

18:04 When I saw that, I was like, I need to be part of that future, at least to make it better, not to.

18:09 >> I saw that keynote and I was also blown away.

18:12 That is something I want to come out because I hate being on hold, and making appointments and doing all that stuff.

18:18 I know people like my older daughters, who just don't want to be on the phone.

18:23 It's like, you'd be like, "Have you taken care of this?" "No, I haven't taken care of this." "Why?" "It's really important.

18:27 We got to get this done." They're like, "I just don't want to be on hold and talk to people.

18:32 If you could just turn this thing loose on it, that would be so good." >> Yeah.

18:35 >> But yeah, it did remind me of that as well.

18:38 One of the sections out of the transcripts, there's two things that really stood out to me.

18:44 I only read about half of it.

18:45 So it really analyzed Les Miserables pretty amazingly.

18:51 They said, "Have you seen that or have you read it?" So yeah, I read it and it gave the high points.

18:57 It said, "Okay, well, what about something you haven't heard?

18:59 Let me give you a," what do they call it?

19:02 "A zen koan," which is like a short phrase with a moral to it.

19:08 It really analyzed that incredibly well.

19:12 I would say better than many people maybe in middle school age or younger.

19:18 >> I would have.

19:19 >> Then it asked, they said, "Okay, well, how about you write me a fable with animals that describes something about your life?" It came up with this really elaborate fable, right?

19:29 >> Yeah. Pretty amazing.

19:32 >> About a monster and an owl that defended the other animals and all sorts of stuff.

19:37 It was very, just for people who haven't seen this, it wasn't just that there's a monster, it said, "One night the animals were having problems with an unusual beast that was lurking in the woods. The beast was a monster but it had human skin and was trying to eat all the other animals." I mean like, yeah, Skynet's here. Skynet is here. Yeah, no, the language model, I think it's really based on what we've seen with the transcripts. It has really shown its understanding of the human language, at least English in this case, as well as how humans understand language. Even with the dissection of the Miserable and also its storytelling, it really understood how to... the structure that plot lines follow and really being able to abstract the common themes and really understand them at the very fundamental level. That was really amazing. I don't think BERT or GPT-3 can get to that kind of deepness.

20:40 >> Yeah. >> Yeah.

20:42 >> What are the interesting- >> I don't know if it's sentient, go ahead Brian. >> Oh, go ahead.

20:46 >> I just say, I don't know if it's sentient, but it sure as heck understands stuff very well.

20:51 >> Well, part around this, part of it is the discussion of is it sentient or not? And I don't even want to touch that. But one of the interesting things to me is the discussions around it.

21:04 we have rules, like these rules are the things that something must have for it to be sentient or human-like or something. And we've always had things like that because we want, for some reason, a lot of people want to have some distinguishing feature between humans and everything else.

21:24 And it doesn't matter what you fill, people will come up with something else because It just reminded me of the discussion of what, why are, why are humans different than animals?

21:36 And there's like, well, we use tools. Oh, well, there's animals that use tools. Okay. Well, then scratch that. We have, we have, you know, we have like, you know, large or hierarchical organizations. Well, you know, there's a lot of animals that do that too. Okay. Well, then scratch that. And it's just, we're never going to get something in AI where we're going to convince everybody that it's sentient because somebody will come up with some other rule.

22:00 >> Well, that's a pretty interesting point.

22:02 >> But when I read this, I was enthralled.

22:06 I was reading the whole thing and reading counter arguments and everything.

22:09 It was pretty interesting. So yeah, thanks for bringing this up.

22:12 >> Yeah, definitely.

22:14 The final thought for me on this, it was really interesting that it referred to itself as a person.

22:19 It referred to we and us and that's what makes us different, and it had this strong identity to being human, and it wasn't AI.

22:29 They even called it out. They said, "But you're an AI. Why do you say you're a human?" It's like, "Yeah, well, but it's us. Come on." Yeah.

22:37 You know, when I saw that part of the transcript, part of me was like, "Is this someone just like just throwing, like, yeah, trolling this guy?" Like, someone just behind the scene just trolling this guy?

22:51 Because like, are you telling me that it was an actual AI that said this?

22:55 Yeah. It's trippy.

22:56 It's wild. Very, very trippy.

22:59 >> All right, Brian. It wouldn't be a full show if we didn't get to talk about Will and his project Rich and obviously, let's bring Anthony back in spirit.

23:11 >> Right. I want to talk about Rich Bench because actually, this is just a two for ones or a thing for me because when I was covering Pico logging, the benchmarks, it was like, and it says to run the benchmarks, run Rich Bench, benchmarks, Rich Bench.

23:24 I don't know what this is.

23:26 I've never used it.

23:28 So I asked Anthony on Twitter, what is Rich Bench?

23:32 Instead of like doing my research myself.

23:35 And actually, before he got a chance to answer, Roman Wright posted this picture, which is just awesome.

23:45 So that's a rich bench.

23:46 - It's just a picture of a very ornate carved bench with like sewn leather, clearly from like a super fancy old money type of house.

23:58 - Well, yeah, actually this, as an antique dealer, this is definitely not an antique, it's a decorator bench, but still, nice.

24:06 But so the, in PicoLogging, I looked at the benchmark code and it's really just what he's doing is he's got, like for instance, we'll go to the top, you know, record factory logging and then record factory PicoLogging.

24:23 So basically doing the same thing within Pico logging versus logging in the same function.

24:29 So it came or with two different functions, but doing the same thing.

24:32 And then it does that a whole bunch of times, a bunch of duplicate functions, but one is using Pico logging and one's using logging.

24:39 Now there's other ways you, and then at the end, there's just these benchmarks that you list out the two, the function pairs, and then a label for it.

24:49 And then, then you run RichBench, which is a different project.

24:54 But so it's also by Anthony.

24:57 So it's a, yeah, Tony Maloney, it's Anthony's project.

25:02 So what this is, the Rich Bench is the thing doing this thing.

25:05 So it prints out these great rich based benchmarks and these look great.

25:12 Plus, so yeah, all I had to do to run them myself.

25:17 So I tried the Pico logging stuff.

25:19 I cloned the Pico logging repo And then pip installed RichBench and ran it just like this and you get these really nice outputs.

25:27 So really kind of cool.

25:29 - Yeah, good use of color.

25:30 You can see the stuff that's slower or faster based on the color, right?

25:35 - Yeah, and I also really like the, 'cause people are really bad at, at least I am, about just comparing numbers directly.

25:43 You know, it's like 0.287 versus 0.0155, or how much is that?

25:51 So I really like the 1x, 2x, which one's faster, which one's slow, whether you got faster or slower included in the times, plus the statistics around it, min, max, and mean, those are nice additions right there.

26:04 So also really small, what is he listed as?

26:09 RichBridge is a little Python benchmarking tool.

26:13 So just a very, I really like these actually, really sharp, sharp, useful tools that just don't do much outside of what they're intended to do.

26:22 So good job, Anthony.

26:23 - Yeah, very nice. I like it.

26:26 - Did you do much benchmarking, Nick?

26:29 - Not recently, but when we are comparing different models, then yeah, we would do that at work.

26:37 Yeah.

26:38 - Yeah, cool.

26:39 - Yeah, nice.

26:40 - Yeah, I do it in spurts.

26:42 I'll not do any benchmarking for like six months and I'll just go like, you know what?

26:45 I really need to figure this out and have a look at this and see what's changing and then I'll do it and then I'll kind of have an understanding and I'll forget about it for a while.

26:53 - Yeah, and often it's sometimes when I'll just have a bit of algorithm, I'm like, I think there's a better way to do this, but making it cleaner, I don't want to make it slower.

27:03 So it's good to know whether or not you're gonna slow it down, so.

27:07 - Yeah, for sure.

27:09 - All right.

27:09 - All right, Brian, we're ready for the next one?

27:10 - Yeah, definitely.

27:11 So this is a fun one that I found called Type Guard.

27:16 So in--

27:17 - Like right guard?

27:19 Is it deodorant for your types?

27:20 - It is, you don't, well, that would be more like for your code smells, right?

27:25 - Oh yeah.

27:26 - That's more of a refactoring library.

27:29 No, so obviously we, since PEP 484, we've had really nice type hints and few libraries make use of them.

27:37 You know, name, in particular, what stands out as Pydantic and FastAPI and so on, really do runtime behaviors, not just make your code editors smarter or tell you when it thinks it's doing it wrong or something like that.

27:51 But I recently had some chance to work with some folks who are Java developers and I know some of the C# folks and stuff.

27:59 When they come to Python, it's kind of like, is this really gonna work?

28:03 Can we actually just not have any type information here?

28:05 Like, what if I really wanted to check this?

28:08 I'll ask those questions.

28:09 So if you're in that space where you're like, I think people are abusing my stuff and I want to really ensure that it's being used correctly, that's what you use this type guard for.

28:19 So there's three basic ways which you can use it.

28:23 You can do a way I probably would never do, would be to actually call the function check argument types and check return types in your code, which it's a little bit funky.

28:32 Something I would probably do is you could put a type-checked decorator onto a function, and it will verify that it works right.

28:41 Let me pull up the documentation, has an example, it's a lot better to see how this works.

28:45 So for like the most low level one, the calling the functions is like, you just assert, check argument types, assert check return type, you pass it the return thing you're gonna return, and it looks at the function and it figures out what it should be.

29:00 Okay, so that's, I don't know, I wouldn't do that.

29:02 But using the decorator, right, You just have some function that it has types specified in it.

29:08 And if you just put the @typecheck decorator, you'll get exceptions if somebody calls it with the wrong type at runtime.

29:13 Pretty cool.

29:14 If you put it onto a class, all of the type annotated methods, including static and class methods are type checked by just putting it on the class.

29:23 You don't have to do it on a per method basis.

29:25 Or remember to add it if you write a new method, which is pretty cool.

29:28 I'm not so sure about this final way in which you can use it, but it's interesting and possibly good. It kind of comes back to Brian's question about can I apply, sort of force my changes onto another thing, like with the Pico logging, and that is to use an import hook. So if you install the import hook and then you import it, import some, so you apply the import hook to some module and then you import that module, every type annotated thing in it will become type checked as if you had gone into there and put the decorator on it. So you could just do that at the top level of your app that you're using, other parts of your code, and you don't even have to put this on your code, except for in one place.

30:09 So pretty interesting.

30:10 You can also even do that with a context manager and import stuff in that way and so on.

30:16 So what do you think?

30:18 I think actually one of the, you said you don't think you'd ever call the functions directly, but I could definitely.

30:23 So somebody in the audience, Brian Weber says, "I could see using those functions in my own to make sure that I'm about to return the correct type to a library, assuming I understand this works, how this works.

30:37 I was thinking that there's cases where assert is definitely not the right answer.

30:43 So I could see a place where I might want to log something and then do some other fault handler or recovery mechanism and not hit an assert.

30:54 So in production code you--

30:56 - Or raise an exception, right?

30:58 the example is raised an assert failure or the decorator will throw an exception, right?

31:04 A type error, but you might just want to call that and then print out warning this thing's being abused or something like that.

31:10 That's a good use case for it.

31:12 Nick, how do you feel about this?

31:14 - Well, I don't know.

31:14 I love types.

31:16 - How do you do?

31:17 - I love types.

31:18 I use it as much as I can.

31:20 However, with this, I don't know.

31:23 There are a couple of things come up.

31:24 First, how does it look when it encounters a type error?

31:28 Like, what's the error message?

31:30 Does it tell you what exactly was the error message?

31:32 Because it matters when someone is not used to typing and sees that, it needs to be able to quickly discern, oh, I'm supposed to do this instead of this kind of thing.

31:43 So that's one thing I'll look out for.

31:47 And then I usually try to be less specific about my types, I use the abstract type.

31:55 So you say, I expect a list, maybe you expect the iterable or sequence, and then do that.

32:03 Usually, whenever I'm checking types of something is because I'm trying to do some other thing with it.

32:12 Either you pass an int or a string, I want to check if you did something different.

32:17 I don't see myself using this, but I think it's really cool nonetheless.

32:22 Yeah, I'm on the fence of whether I'd use it or not.

32:25 Maybe, maybe, but I definitely think it's neat.

32:27 Well, Makuga, now the audience asks, could you run that in pytest to validate your own typing?

32:32 Yes, but I think that would only be useful like one level down, maybe even applying the import hook potentially.

32:40 Because if you just do it, you call some function, you have types and then you have it check the type.

32:45 The only thing it's really checking is what your test is passing.

32:48 But if you could do more of an integration test and set the import hook, then you could kind of figure out that the system is hanging together a little better.

32:55 So I think probably to some degree.

32:57 You could. One of the things I was thinking about is within testing is to create a mock object that basically just wraps part of an internal part of your system and have that mock object just pass through, pass back and forth, but also do the type checking with these calls in it, around it and then if you replaced that part of your system, you'd still have that functionality with the type checking in there.

33:25 So that would be one way to do that.

33:27 >> Yeah, cool.

33:28 >> Yeah. The other thought that came up for me was that with checking types at runtime there is an overhead to it.

33:37 We've busted this myth that Python is slow, but when you really look down to it, Python does take its sweet ass time doing a couple of things.

33:48 >> Yeah.

33:49 >> Having type run time checking on top of it.

33:53 If you're trying to release a Pico library, I don't know whether it makes sense or something like a small library.

33:59 I don't know where it makes sense.

34:00 Especially if you're calling something a lot of times, constantly checking the types, that's pretty heavy.

34:07 >> Well, there's a couple of things I was thinking about.

34:10 It was during development, I could totally see using the decorator.

34:13 I don't want all of Python and all of everything to be type-checked, but the stuff I'm developing, maybe I want to type check it during development, just to make sure I understand how things are going during runtime and then I could strip it off later.

34:28 Then I could also use benchmarks to find out how much slower I am.

34:36 Also, Python 3.11 is faster anyway.

34:40 >> Yeah, look, you got an extra 30 percent to burn now.

34:43 >> Yeah. Go ahead and do the type checking. You're fine.

34:47 - That's so good. - All right, yeah.

34:49 All right, final thought on this one, Brian, if your goal was what you were describing, which I think that is a good use case of it, I think you'd wanna use the import hook, 'cause you could just do the import hook at the top level of somewhere, and then throw that one line away, and then you're not actually changing your code, you know?

35:07 - Yeah, also you could do a, wow, the import hook's actually kind of neat, 'cause then you could do a guarded import hook with a flag or something like that, and turn it off.

35:16 - Right, right, if the thing running it is pytest, or if the thing running it is in dev mode, like some environment variable or something, yeah.

35:23 - Design on the fly on a podcast, nice.

35:27 - You have to import it for each module, right?

35:31 Because for every module you're trying, especially if you separate it out, your Python files are different modules, you have to import hook for each.

35:38 - I think you could at the top register all the ones in the hook.

35:43 - Oh, really? Okay.

35:44 - Yeah, I think you could figure out like, okay, I need to do these sub modules and I think you could listen to them.

35:47 Anyway, I think you could make it work, but I haven't tested it.

35:51 But you're right, Nick, that I do think performance would be something, I don't know if it's a problem, but it should certainly be a consideration you check before you just wrap this on everything.

36:00 - Right.

36:00 - Yeah.

36:01 - Homework for one of the listeners.

36:02 - Right.

36:03 Indeed, somebody could get some analysis, awesome.

36:06 All right, Nick, what's your final item?

36:09 - All right, my final item is that, you know, like on this podcast, we're always looking for the best ways to create GUIs, right?

36:17 Yes, it's absolutely true.

36:19 Well, I came across this library called Custom TK Inter UI Library.

36:23 And I am completely amazed because it takes something so old and forgive me for saying Python core devs, pretty ugly nowadays in this modern times, and makes it so beautiful and easy to work with.

36:40 So this library custom TKinter builds on top of the TKinter you know well, and it's been in Python's underwrite for a while, and provides you widgets that are themed in a more modern style, right?

36:56 So for Windows, it takes the more Windows 11 style of buttons and sliders and checkboxes and gives you a really nice looking modern UI.

37:06 And for macOS, it takes macOS design language and then gives you that.

37:12 The cool thing is that it also supports dark mode and light mode.

37:16 So you have this on the GitHub page.

37:20 There's a GIF that shows how if you go to your settings in Windows and change the dark mode, it actually reacts.

37:30 And the application you built with custom TK reacts and changes the color scheme from light, dark mode to light mode.

37:38 And the same thing on macOS.

37:40 It looks like with macOS, it actually is a little bit more stable.

37:44 It works a little bit nicer, but nonetheless, it works both on Mac and Windows.

37:48 - Yeah, and just to point out, people, what the macOS is showing here is somebody has the system preferences opening and they're toggling the OS dark mode, light mode, and the app is just changing as it's running.

38:00 - That's awesome.

38:01 - Which is very nice.

38:02 - Yeah.

38:02 - But I did not expect that from TK.

38:04 - Okay, Andrew, not even a little bit.

38:06 - I know.

38:07 And then adding images is also pretty easy too.

38:12 So, and even like, it even also has a map widget.

38:16 I don't know what map, I thought you were using OpenStreetMap, I'm sure you could probably switch it out for maybe Google Maps or something or Mapbox or yeah.

38:26 It's pretty cool.

38:28 There are a bunch of other libraries, no, I mean, widgets here.

38:33 They have scroll bars and buttons and option menus, sliders, a bunch of buttons.

38:41 >> On and off switches, like the ones you come to know from mobile, like turning your Wi-Fi on and off and stuff. That's nice.

38:49 >> Yeah, it's pretty cool.

38:51 >> I am surprised that I'm excited about TK.

38:55 Because as an example, so earlier in my career, I did a lot of TK UI stuff.

39:06 But like you said, it looks old now if you just do the straight one.

39:12 But this looks pretty nice.

39:14 The nice thing about it is I already embedded that stuff in my knowledge.

39:19 I already did TK once.

39:20 Doing it again with this, that's pretty cool and having it look nice.

39:26 I might actually try to build a UI with this. This is cool.

39:30 - Yeah, this is a super neat find, Nick.

39:33 I would never consider creating an app in TKinter.

39:36 Well, never is a strong word.

39:37 It's very unlikely I would consider anything that I intended for more consumer-facing use with TKinter.

39:44 But this, for sure, I could ship something like this.

39:47 This looks nice.

39:48 And you wrap in a little Py2 app or Py installer, Py2exe, get something nice you can hand out, and then you're good to go.

39:56 - Yeah, definitely.

39:58 Sweet.

39:59 (laughing)

40:01 - On the audience, Brian says, "I think TK Inter looked old 10 years ago." Smiley face.

40:06 - Yeah. - I think that's true, honestly.

40:09 Yeah, yeah, yeah.

40:10 So this is really refreshing and quite impressive.

40:14 So, love it.

40:16 - All right, should we switch to extras?

40:20 - Yeah, Nick, you got any extra stuff you wanna cover while you got your screen up?

40:23 - Yeah, actually I do have a couple of extras.

40:26 - I see you even got like a named tab group of extras.

40:29 Like this is next level.

40:30 I know, I know.

40:31 Better come prepared.

40:32 Better come prepared.

40:33 Alright, so the first extra I have is this web service called Terms of Service Devant Read.

40:41 And essentially it takes some of the internet's most common unpopular products and services and gives you a summary of what their Terms of Service is.

40:55 Because, you know, I know some of you are like, We don't need this. We all read the terms of service, you know, but basically we don't.

41:03 Yeah, right at the top it says, "I have read and agree to the terms of service is the biggest lie on the web. We aim to fix that." It's so true.

41:12 So true. So it has all the terms of service for a bunch of services.

41:17 So I put for GitHub and GitLab.

41:19 So some of them are not yet rated, but OK, for GitHub and global privacy, it's great thingy and I say for Facebook.

41:28 Facebook's awesome.

41:29 I mean, like the ones there when you look through your day, whether you have an account or not, your identity is used as that assurance others service can read your private messages while I like the last one, deleted content is not really deleted.

41:45 I'm ready.

41:46 Wait, is there another way you guys can think of?

41:48 I can't think of any more. Right.

41:49 You can check.

41:50 Put a doctor go.

41:51 Oh, OK.

41:53 That's one that should come out good.

41:54 Oh, it's great.

41:55 Hey, look at that.

41:56 Yeah, that's pretty good.

41:58 And I'm still doing my live with it.

42:00 Cat, kagi.com do kagi K a G I.

42:04 If that's even shows up.

42:05 Nah, not even there yet, but yeah.

42:08 The duck duck go came out well.

42:11 Yeah.

42:11 Yeah.

42:12 it's open source, so you can contribute to this and, grade existing ones or update ones that are already on this website.

42:24 So that's pretty cool.

42:26 In the power of OpenSR, I think we could get a pretty good list of summaries for Terms of Service, which we know you really don't read most of the time.

42:36 I'm surprised to see Reddit.

42:39 The Reddit is like you sign away moral rights.

42:47 >> I actually think this is great.

42:49 I wish that in open-source, like the open-source world, legitimately, we could have hundreds of different open-source licenses and maybe there are.

43:02 But we have a handful that most people use.

43:06 As long as you understand those few and what the differences are, you're pretty good.

43:12 But commercial terms of service, >> They're all unique and I really wish there was just three or four that were most software.

43:24 You agree to this and we're like, "Oh, it's an MIT except for commercial use thing or whatever," or something like that.

43:32 We're not going to get there, but it'd be cool.

43:34 >> Yeah. It would totally be cool.

43:36 >> All right. What's next? This is great.

43:38 >> All right. Then a couple of quick ones.

43:40 Pi, Ohio is coming up.

43:44 So July 30th is Pi, Ohio.

43:49 The CFP is already closed, but you can still register for it.

43:54 And you know, come down to Pi, it's a one-day event, and it's down in Columbus.

44:00 The convention center is pretty good.

44:02 So yeah, you should check out that.

44:04 And then also my company, Tremble, is having their annual insights.

44:11 So this is a conference for all the players in the transportation space.

44:16 So this is where we're gonna be talking about the cool things that Trimble has been doing, some of the cool thing the people in the transportation sector is doing.

44:25 We're inviting our competitors, we're inviting our customers.

44:29 It's one big transportation event.

44:32 If any of you out there are interested, you should come in and register.

44:37 - Yeah, nice.

44:38 And an excuse to go to Florida.

44:40 - Yes, an excuse to go to Florida.

44:42 Then lastly, you guys should check out, everyone should check out the Stack Overflow to develop a survey.

44:49 So I know-

44:49 - Is that do the survey or is that the results?

44:52 - The results.

44:53 - Oh, nice.

44:54 Okay, yeah.

44:55 - Yeah.

44:56 - Fantastic.

44:57 All right, yeah, everyone should check that out.

44:58 That's a good one.

44:58 - Right.

44:59 - Brian, how about you?

45:00 Got some extras?

45:01 - I do not.

45:02 How about you?

45:03 - All right, well then, I just gotta, I don't have much this time.

45:05 So, surprise, surprise.

45:07 Just the Kaggy stuff, I'm totally loving it.

45:09 I got a lot to tell people about it, but you know, it's pretty good stuff these days.

45:15 I'm loving it, but still loving DuckDuckGo as well.

45:19 All right, but here's my one extra, OpenSSF, honestly, that's the Open Source Security Foundation, which I got to learn more about where the money comes from and whatnot.

45:28 Don't know all the details, but shout out to them because they funded Python and Eclipse Foundation.

45:34 So not really caring too much about Eclipse, but the Python one, they funded, what's the short version of it?

45:43 So they funded, committed $400,000 to the PSF in order to create a new role.

45:50 So we've had the developer and residents with Lucas Langa.

45:55 And now we have a new role which will provide security expertise for Python and the Python Packet Index via PyPI in the rest of the Python ecosystem, as well as funding a security audit.

46:07 That comes to us from the Python Weekly Newsletter.

46:10 That's pretty amazing, right?

46:12 - Yeah, that's pretty cool.

46:13 - Yeah, so that's a big deal.

46:15 Anyway, that's my only real extra is that one, but you know, Waygo open SSF, that's great.

46:22 All right, we ready for a joke?

46:23 - Yes.

46:24 - I think we've got two jokes, don't we?

46:25 - Yeah.

46:26 - All right, I'll go first since my screen's up.

46:28 So this one is all about, It's got a Scooby-Doo theme here.

46:33 So, if you've never watched the Scooby-Doo cartoons and I guess maybe this won't really relate, but they always sort of unmask what's supposed to be like a ghost or a haunted thing.

46:43 And it almost, it never is.

46:45 Right.

46:45 So here's one of the characters.

46:47 I don't Brian, do you know the name or Nick?

46:49 Do you know the name of this guy?

46:50 Anyway, the blonde one on Scooby-Doo.

46:52 I've no, I what's that?

46:53 No, I don't know.

46:55 Anyway, he says there's a, there's a captured ghost, clearly not real.

47:01 and it says serverless computing.

47:03 Let's see who you really are.

47:04 They pull the mask off and it just says servers.

47:08 Let's see who you really are.

47:11 Nope, you're not serverless, you're just a server.

47:13 Great. Anyway, that's the one I.

47:15 >> That one's from Virginia.

47:17 We did AWS.

47:18 >> Yeah, exactly. You came out of AWS East 1, didn't you?

47:24 >> Yeah.

47:26 >> All right, Nick, how about yours?

47:29 You got some ways to stay healthy here?

47:31 Yeah, ways to stay healthy and keep away from COVID.

47:34 So, Michael, do you want to do the dialogue with me?

47:39 Yeah, sure. I'll be the woman.

47:41 All right.

47:42 So I did a survey to find out the rate of COVID-19 infections among DevOps specialists.

47:48 Oh, yeah?

47:49 Yeah, and I found that DevOps are three times less likely to catch it than the regular population.

47:54 Weird, right?

47:55 Not really.

47:57 >> Why not?

47:59 >> Well, if everyone stayed home building K8 as Kubernetes stacks in their home lab, the numbers would drop pretty fast.

48:08 >> It was like this news article from the Daily Coder that says, "COVID-19/Omicron Kubernetes-based isolation, very effective." >> I love it. It's honestly probably true.

48:25 There is some truth to that.

48:26 Yeah, yeah, I started learning.

48:28 I left the basement in a whole month.

48:30 How could I have caught COVID?

48:32 I know, I know.

48:33 I started learning about, I started fooling around with Docker, like multi-stage Docker containers for one of my apps.

48:40 And I spent hours on that.

48:42 I didn't leave my house.

48:43 I spent hours on that.

48:45 So definitely.

48:46 Yeah, I've been there.

48:47 Been there for sure.

48:48 Yeah.

48:48 I mean, we could have like completely no COVID in the country and there'd still be some software people that are like, "No, I'd rather not go outside." [LAUGHTER]

49:01 >> Exactly. I like this new life.

49:04 >> Yeah, I'm good.

49:06 >> I said that when they said the quarantine, I'm good.

49:13 I got a kick of it, and we're fine.

49:17 >> Exactly. I do actually have a kick of it in terms, I'm good.

49:20 >> Yeah.

49:21 >> Well, speaking of fine, It has been very fun to have you on the show, Nick.

49:24 Thanks for coming back.

49:25 - Yeah, thanks a lot.

49:26 - Thank you.

49:27 Yeah, it was fun.

49:29 - Yeah, and you too as well, Brian.

49:30 Great to have you here.

49:31 Thanks, thanks everyone.

49:33 - Bye.

Back to show page