WEBVTT 00:00:00.001 --> 00:00:06.040 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds. 00:00:06.040 --> 00:00:12.780 This is Python Bytes, episode 43, recorded on September 13, 2017. 00:00:12.780 --> 00:00:15.060 And I'm Michael Kennedy. 00:00:15.060 --> 00:00:16.040 And I'm Brian Okken. 00:00:16.040 --> 00:00:18.320 Hey, it's great to be with you guys. Great to be with you, Brian. 00:00:18.320 --> 00:00:21.380 We have a bunch of really cool stuff lined up. 00:00:21.380 --> 00:00:26.260 There's a few things that really surprised me and maybe even inspired me to go create this project 00:00:26.260 --> 00:00:27.940 that we were just chatting about before we hit record. 00:00:27.940 --> 00:00:30.180 So very, very cool stuff. 00:00:30.180 --> 00:00:32.800 But before we get to it, let's just say thank you to Rollbar. 00:00:32.800 --> 00:00:34.560 Those guys are sponsoring the show. 00:00:34.560 --> 00:00:38.980 You check out their offers at pythonbytes.fm/Rollbar, and we'll get to them later. 00:00:38.980 --> 00:00:44.260 I want to talk about taking the future and sending it into the past, like Marty McFly style. 00:00:44.260 --> 00:00:45.160 What do you think? 00:00:45.160 --> 00:00:45.460 Yeah. 00:00:45.460 --> 00:00:51.160 Yeah, this popped up recently, just this last week. 00:00:51.160 --> 00:00:56.260 And I'm not sure what the impetus was, but it is Future F-Strings. 00:00:56.260 --> 00:00:57.580 It's a project. 00:00:57.580 --> 00:01:01.160 You could just do pip install future dash F-Strings. 00:01:01.160 --> 00:01:04.980 And then you've got a little bit of a little... 00:01:04.980 --> 00:01:06.840 It isn't a library that you include. 00:01:06.840 --> 00:01:09.380 It changes the encoding. 00:01:09.380 --> 00:01:11.760 So I'll just jump to the chase. 00:01:11.760 --> 00:01:15.560 It's a back port of F-Strings, even down to Python 2.7. 00:01:15.560 --> 00:01:18.400 And I've tried it in 2.7. 00:01:18.400 --> 00:01:20.340 I haven't tried it in anything else. 00:01:20.460 --> 00:01:23.880 But it is kind of fun to be able to play with F-Strings everywhere. 00:01:23.880 --> 00:01:28.360 So I had very mixed thoughts about this when you told me about this project. 00:01:28.360 --> 00:01:38.840 On one hand, I look at it like, you know, you're taking one of the really amazing and smooth features of Python 3.6 and making it available in legacy Python. 00:01:39.120 --> 00:01:42.880 Which is kind of like, do we really want to like encourage that sort of thing? 00:01:43.380 --> 00:01:52.420 But at the same time, I feel like this also lets you, as you're migrating your code, move to the latest, greatest syntax in Python 2. 00:01:53.000 --> 00:01:59.920 But then when you actually make the switch, you're not going to have to go like, well, we used format because that was the best option in Python 2. 00:01:59.920 --> 00:02:01.680 But now we've got F-Strings. 00:02:01.680 --> 00:02:04.140 And so I feel like that's really cool. 00:02:04.140 --> 00:02:06.840 The other area where I think it's great is Python 3. 00:02:06.840 --> 00:02:09.760 There's plenty of people running Python 3.5. 00:02:09.760 --> 00:02:13.720 That's the default on Ubuntu right now and things like that that don't have F-Strings. 00:02:13.720 --> 00:02:19.180 I've decided after further contemplation that this is a really cool project and I want to check it out. 00:02:19.180 --> 00:02:21.500 So tell people what F-Strings are. 00:02:22.180 --> 00:02:26.880 I mean, most people maybe know, but what's this thing, this F-String thing? 00:02:26.880 --> 00:02:36.040 Well, it's, so if you're familiar with the format part that you could be, I don't know how long ago you start using that. 00:02:36.040 --> 00:02:37.720 I think that's available in 2.7 as well. 00:02:37.720 --> 00:02:38.200 Yeah, I think so too. 00:02:38.200 --> 00:02:44.160 In the string that you're printing, you can like leave little brackets to show where you're going to insert something. 00:02:44.160 --> 00:02:48.800 And then you say like .format and then all the things that you're going to put into the string. 00:02:49.400 --> 00:02:56.760 In F-Strings, you just put an F before the string and then within your brackets, you just put the variable name for whatever you're going to put in there. 00:02:56.760 --> 00:02:59.060 Or any expression can go in there. 00:02:59.060 --> 00:02:59.360 Right. 00:02:59.360 --> 00:03:07.060 So you could say like F, quote, hello curly thing dot upper and like uppercase the thing just in that expression or something like that, right? 00:03:07.060 --> 00:03:07.340 Yeah. 00:03:07.340 --> 00:03:07.800 Yeah. 00:03:07.960 --> 00:03:08.680 That's really cool. 00:03:08.680 --> 00:03:09.300 Yeah. 00:03:09.300 --> 00:03:14.100 At first I was like, I don't know if I like it, but once you start using F-Strings, you can't go back. 00:03:14.100 --> 00:03:26.260 That's really one of the reasons why I like this project is because I do, I usually use Python 3.6, but there are times where I have to write some stuff in 3.5 or 2.7 or something. 00:03:26.260 --> 00:03:27.800 And I don't want to go back. 00:03:27.800 --> 00:03:28.240 Yeah, I know. 00:03:28.240 --> 00:03:28.780 I hear you. 00:03:28.780 --> 00:03:29.300 That's great. 00:03:29.540 --> 00:03:36.960 I'm going to put a lot of tests around it, so I'm not going to rely on this yet because I don't know if it's really ready for primetime for everywhere. 00:03:36.960 --> 00:03:41.260 So I would say use caution, dip into this slowly if you're going to use it. 00:03:41.260 --> 00:03:43.120 But it's a fun thing. 00:03:43.120 --> 00:03:46.260 I'm not sure I like how it's doing it though. 00:03:46.260 --> 00:03:49.620 It's doing it in an interesting and odd way. 00:03:49.620 --> 00:03:49.900 Yeah. 00:03:50.260 --> 00:03:54.080 I don't know how else it would do it, but it's interrupting the encoding. 00:03:54.080 --> 00:03:56.420 Yeah, it installs a separate encoder. 00:03:56.420 --> 00:04:02.320 So it extends the UTF-8, I think, the UTF-8 encoding to also do this. 00:04:02.320 --> 00:04:08.100 So if you're not using UTF-8, I don't know, maybe you could hack it to do something like you're using. 00:04:08.100 --> 00:04:09.680 Yeah, yeah, it's pretty cool. 00:04:09.680 --> 00:04:14.920 So you put like a little encoding flag at the top and you install a special encoder and off it goes. 00:04:14.920 --> 00:04:15.680 Yeah, pretty interesting. 00:04:16.340 --> 00:04:23.160 All right, so I want to stick with this Python 3.6 feature angle, even though that's bringing that stuff to other versions of Python. 00:04:23.160 --> 00:04:26.500 I want to talk about the fun of reinvention. 00:04:26.500 --> 00:04:31.040 So this was a really amazing presentation done by David Beasley. 00:04:31.040 --> 00:04:35.160 And it's done in the style of some of his other presentations. 00:04:35.160 --> 00:04:38.760 And in my mind, like the way technical presentations should be done. 00:04:38.760 --> 00:04:44.060 You should be up there writing code, showing how things work, not just slides and pictures and stuff, 00:04:44.160 --> 00:04:46.600 but like showing things, right? 00:04:46.600 --> 00:04:50.180 And so what he shows, though, is kind of insane and incredible. 00:04:50.180 --> 00:04:52.420 And your mind will probably explode if you see this. 00:04:52.420 --> 00:04:55.740 You'll definitely come away with a greater appreciation for Python 3.6. 00:04:55.740 --> 00:05:04.600 So what he does is he goes and builds upon some of the new 3.6 features that are below the surface 00:05:04.600 --> 00:05:08.640 that a lot of people wouldn't even know about, like hooking into when a class gets defined. 00:05:09.020 --> 00:05:13.020 So you can basically redefine what that means and things like that. 00:05:13.020 --> 00:05:15.680 So, for example, he says, well, let's talk about type-ins. 00:05:15.680 --> 00:05:17.780 These type-ins are cool, but they don't do anything. 00:05:17.780 --> 00:05:22.740 We can add these constraints and assertions inside of our code, and that does something, 00:05:22.740 --> 00:05:25.840 but we can't really check that in the tooling. 00:05:26.020 --> 00:05:32.180 So what if we could rewrite, create this little framework using inheritance and all sorts of other stuff 00:05:32.180 --> 00:05:38.140 that lets us add these constraints as type-ins, and then they're enforced at runtime automatically. 00:05:38.140 --> 00:05:39.240 It's pretty amazing. 00:05:39.240 --> 00:05:40.320 That's incredible, yeah. 00:05:40.320 --> 00:05:40.540 Yeah. 00:05:40.540 --> 00:05:43.940 So whether you think it's a good idea or a bad idea to do that, 00:05:43.940 --> 00:05:46.320 the fact that you can do that is really, really cool. 00:05:46.400 --> 00:05:50.500 So you can basically set up a function, and as like a type hint constraint, 00:05:50.500 --> 00:05:54.880 you can say, and this is a positive integer between 0 and 200. 00:05:54.880 --> 00:05:58.240 And it will actually check that. 00:05:58.240 --> 00:05:59.140 It's really something. 00:05:59.140 --> 00:06:01.800 But mostly it's an amazing look inside. 00:06:01.800 --> 00:06:06.120 Yeah, it's an amazing look inside of Python 3.6, down at the low-level stuff. 00:06:07.400 --> 00:06:10.600 So, Brian, knock, knock, who's there? 00:06:10.600 --> 00:06:13.540 Yeah, I am. 00:06:13.540 --> 00:06:14.520 Sound recognition is there. 00:06:14.520 --> 00:06:16.460 Yeah, sound recognition. 00:06:16.460 --> 00:06:21.280 So there's an interesting article called Sound Pattern Recognition with Python, 00:06:21.280 --> 00:06:26.620 and I really liked just the – I didn't know you could do this with SciPy. 00:06:26.620 --> 00:06:32.120 So there's apparently part of SciPy.io.wave file, 00:06:32.120 --> 00:06:36.300 and I'm not sure if there's other types you can do – use. 00:06:36.680 --> 00:06:41.000 But this article uses SciPy to read a WAV file 00:06:41.000 --> 00:06:45.880 and then just has it as data, like an array of numbers, 00:06:45.880 --> 00:06:47.600 and then does some math on it. 00:06:47.600 --> 00:06:51.440 And it does – this particular one is assuming that you've got some WAV files 00:06:51.440 --> 00:06:52.620 that have NOCs in them 00:06:52.620 --> 00:06:56.940 and trying to detect where the NOCs are and how far away they are. 00:06:56.940 --> 00:07:00.820 And just some basic little logic to try to figure out, 00:07:00.820 --> 00:07:02.460 yeah, like I said, where the peaks are. 00:07:02.460 --> 00:07:05.880 I think the author noticed that you need to have some minimum values 00:07:05.960 --> 00:07:10.000 for how you tell where the peaks are and then some distance between them 00:07:10.000 --> 00:07:12.460 so you don't have, like, ringing within one peak. 00:07:12.460 --> 00:07:17.380 I like it because it's kind of a – I think it would extend easily to do – 00:07:17.380 --> 00:07:21.180 I'd like to take it and run with it and try to do some basic oscilloscope measurements 00:07:21.180 --> 00:07:23.480 with this kind of a thing. 00:07:23.480 --> 00:07:24.240 It'd be fun. 00:07:24.240 --> 00:07:25.300 Yeah, it'd be super fun. 00:07:25.400 --> 00:07:26.620 It's really accessible. 00:07:26.620 --> 00:07:30.600 Like, the actual code to figure out the NOCs and to process the WAV file, 00:07:30.600 --> 00:07:32.780 it's really small and approachable. 00:07:32.780 --> 00:07:35.580 And to me, what I thought of when I heard this was, 00:07:35.580 --> 00:07:38.400 oh, you could build something that is actually kind of smart. 00:07:38.400 --> 00:07:41.340 So it shows you how to identify NOCs, right? 00:07:42.000 --> 00:07:46.760 And you should be able to identify, like, a door jiggling, a key noise. 00:07:46.760 --> 00:07:50.520 You should be able to identify, like, a few of these really distinct patterns. 00:07:50.520 --> 00:07:54.540 And if you could say, like, identify, like, what does a door jiggle sound like? 00:07:54.540 --> 00:07:56.360 What does a knock? 00:07:56.360 --> 00:07:57.260 What does a doorbell? 00:07:57.260 --> 00:07:59.040 What does a key sound like? 00:07:59.040 --> 00:08:01.760 You could put a little Raspberry Pi just by your front door that says, 00:08:01.760 --> 00:08:04.860 someone's home, someone unlock the door, someone's knocking. 00:08:04.860 --> 00:08:06.900 You know, just cool stuff. 00:08:06.900 --> 00:08:10.180 Wouldn't that be – I mean, it seems like that's a weekend project with this. 00:08:10.180 --> 00:08:11.000 It doesn't seem major. 00:08:11.000 --> 00:08:12.280 Yeah, that would be fun. 00:08:12.280 --> 00:08:16.700 You could hook it up with Twilio and get texts when somebody's knocking at your door. 00:08:16.700 --> 00:08:19.780 Right, and hook it up with a camera to take a picture of whoever's out there, 00:08:19.780 --> 00:08:20.820 see what they're doing, right? 00:08:20.820 --> 00:08:21.180 Yeah. 00:08:21.180 --> 00:08:21.440 Yeah. 00:08:21.440 --> 00:08:23.320 Send yourself a note, hey, kids came home, right? 00:08:23.320 --> 00:08:26.040 They unlock the door at 3 o'clock when school's out or whatever. 00:08:26.040 --> 00:08:26.700 That would be fun. 00:08:26.700 --> 00:08:27.360 It sure would. 00:08:27.360 --> 00:08:28.060 All right. 00:08:28.160 --> 00:08:31.400 So I think people should take this idea and run with it. 00:08:31.400 --> 00:08:33.400 And if they do, they should send us a message. 00:08:33.400 --> 00:08:39.200 Or even better, go to pythonbytes.fm/43 and leave a comment at the bottom about what they created. 00:08:39.200 --> 00:08:40.600 Yeah, definitely. 00:08:40.600 --> 00:08:41.180 Definitely. 00:08:41.180 --> 00:08:44.500 Or even better, they could write a blog post and then email that to us, 00:08:44.500 --> 00:08:45.700 and we'll highlight it on the show. 00:08:45.700 --> 00:08:46.800 Yeah, maybe we'll even cover it. 00:08:46.800 --> 00:08:47.280 That'd be awesome. 00:08:47.280 --> 00:08:47.940 Yeah, yeah. 00:08:47.940 --> 00:08:49.000 Cool. 00:08:49.000 --> 00:08:51.860 So before we get to the next item, which is sort of mind-blowing, 00:08:51.860 --> 00:08:53.340 I want to talk about Rollbar. 00:08:53.340 --> 00:08:56.880 You guys hear me talk about Rollbar a lot probably, but that's because they're great. 00:08:57.280 --> 00:09:02.680 Basically, if you run any sort of web app, you should have real-time error monitoring and reporting. 00:09:02.680 --> 00:09:08.240 So if something goes wrong with the website, for example, pythonbytes.fm, we'll get a notification. 00:09:08.240 --> 00:09:09.460 It could be in Slack. 00:09:09.460 --> 00:09:10.280 It could be on our phone. 00:09:10.280 --> 00:09:11.720 They don't have all the details. 00:09:11.720 --> 00:09:14.900 You know, this person went to this URL in this situation. 00:09:14.900 --> 00:09:19.260 Here's the variables they passed to the function that caused a crash, things like that. 00:09:19.320 --> 00:09:25.920 So if you want to get this for your site or application, just go to pythonbytes.fm/rollbar and check it out. 00:09:25.920 --> 00:09:29.660 So we've talked a lot about async stuff, right? 00:09:29.660 --> 00:09:32.600 Like async both on the server and on the client. 00:09:32.600 --> 00:09:35.240 It's pretty mind-blowing stuff. 00:09:35.240 --> 00:09:44.360 But it turns out that, you know, like all changes to software, there's like cascading consequences of adopting a new model or trying something new, right? 00:09:44.360 --> 00:09:52.300 And one of the cascading changes is in many of the high-performance async processing loops. 00:09:52.300 --> 00:09:57.200 I'm thinking async.io, but also uv loop, which is a really super fast, powerful one. 00:09:57.280 --> 00:10:01.480 Things like Sanic are, I think Sanic is based upon it, the web framework and so on. 00:10:01.480 --> 00:10:08.900 Those things are ultra fast because they rely on async.io, but async.io doesn't use threads. 00:10:08.900 --> 00:10:16.720 And so that means thread local storage doesn't have any meaning anymore when all of these like concurrent operations are running on the same thread. 00:10:16.720 --> 00:10:17.200 Okay. 00:10:17.200 --> 00:10:17.620 Right? 00:10:17.620 --> 00:10:23.540 So like if I was running a website, I might store into thread local storage like the cookies or the authentication. 00:10:23.540 --> 00:10:25.960 And then later I might ask for it back. 00:10:26.220 --> 00:10:32.340 But that could be changed because you have a blocking.io that released the thread that somebody else then wrote their cookie to. 00:10:32.340 --> 00:10:32.580 Right? 00:10:32.580 --> 00:10:33.580 So it's kind of like crazy. 00:10:33.580 --> 00:10:36.980 And there's also in other really interesting places like decimals. 00:10:36.980 --> 00:10:38.500 Working with decimals does this. 00:10:38.500 --> 00:10:39.640 NumPy error state. 00:10:39.640 --> 00:10:40.880 Warnings.catch warnings. 00:10:40.880 --> 00:10:42.280 Profiling. 00:10:42.280 --> 00:10:43.260 Tracing. 00:10:43.260 --> 00:10:45.220 All these things use this kind of stuff. 00:10:45.220 --> 00:10:45.480 Right? 00:10:45.480 --> 00:10:48.460 But it doesn't work in this async await world. 00:10:48.460 --> 00:10:50.420 So we have a new PEP. 00:10:50.420 --> 00:10:54.640 PEP 550 that defines a new execution context. 00:10:54.640 --> 00:10:58.000 And this is from the guys at magic.io who created uv loop. 00:10:58.000 --> 00:11:00.040 So like their motivation is really obvious. 00:11:00.040 --> 00:11:02.800 Like they want uv loop to work. 00:11:02.800 --> 00:11:04.820 And this is kind of something in the way. 00:11:05.000 --> 00:11:16.620 So the PEP adds a new generic mechanism for ensuring consistent access to non-local state in the context of out-of-order execution such as generators and coroutines. 00:11:16.620 --> 00:11:17.120 Wow. 00:11:17.120 --> 00:11:18.220 It's pretty fascinating, right? 00:11:18.220 --> 00:11:18.620 Yeah. 00:11:18.620 --> 00:11:19.520 It's very fascinating. 00:11:19.520 --> 00:11:21.180 I hadn't even realized that. 00:11:21.280 --> 00:11:23.280 I mean, you think it through, obviously, it's a problem. 00:11:23.280 --> 00:11:24.700 But I hadn't even realized, like, oh, my gosh. 00:11:24.700 --> 00:11:27.240 Like, some of these, like, low-level things are just going to be broken. 00:11:27.240 --> 00:11:30.620 Like how, for example, state is processed in a web request. 00:11:30.620 --> 00:11:33.720 I'll be very interested to watch this and see where it goes. 00:11:33.720 --> 00:11:34.020 Yeah. 00:11:34.060 --> 00:11:36.600 So maybe it makes it into Python 3.7. 00:11:36.600 --> 00:11:37.320 Maybe not. 00:11:37.320 --> 00:11:40.700 But it's kind of cool that this is not just like, oh, we made uv work properly. 00:11:40.700 --> 00:11:43.700 But we're going to make all the Python work properly. 00:11:43.700 --> 00:11:47.720 So they've got some really nice examples on the article we're linking to. 00:11:47.720 --> 00:11:51.220 That's really cool that they did it instead of just trying to hack their own way. 00:11:51.220 --> 00:11:51.460 Yeah. 00:11:51.460 --> 00:11:51.940 For sure. 00:11:52.460 --> 00:11:55.120 Speaking of threads and processing and all that. 00:11:55.120 --> 00:11:59.580 I often work in single-threaded or single-process sort of tasks. 00:11:59.580 --> 00:12:04.580 I really like this article called Intro to Threads and Processes in Python. 00:12:04.580 --> 00:12:08.700 It's a very accessible beginner's guide to parallel programming. 00:12:08.700 --> 00:12:11.080 And really kind of what's the difference? 00:12:11.080 --> 00:12:12.180 Where would you use threads? 00:12:12.180 --> 00:12:13.340 Where would you use processes? 00:12:13.340 --> 00:12:20.280 And it's even got pictures with some algorithms to see to show how, like, if you're a certain 00:12:20.280 --> 00:12:21.220 kind of a job. 00:12:21.300 --> 00:12:23.260 I can't remember what the job is that he's doing. 00:12:23.260 --> 00:12:29.860 He's doing some data science project based on Amazon and trying to analyze a bunch of different 00:12:29.860 --> 00:12:30.920 stuff from space. 00:12:30.920 --> 00:12:35.360 And so he's got to run tons of algorithms and tweak them with different parameters and stuff 00:12:35.360 --> 00:12:35.720 like that. 00:12:35.720 --> 00:12:41.560 It shows, like, basically, if you use one thread, two threads, or four threads, and then the same 00:12:41.560 --> 00:12:45.720 with processes, how it's affected with running times. 00:12:45.720 --> 00:12:48.880 And you can watch to see that things are running in parallel. 00:12:49.580 --> 00:12:51.480 Good use of little simple diagrams, too. 00:12:51.480 --> 00:12:51.920 That's cool. 00:12:51.920 --> 00:12:52.920 Yeah, the pictures were great. 00:12:52.920 --> 00:12:58.680 The rundown is, conclusion at the end is, if you're waiting on I.O. for something, threads 00:12:58.680 --> 00:12:59.340 are just fine. 00:12:59.340 --> 00:13:03.960 And if you are CPU heavy, then you want to go with multiprocessing. 00:13:04.020 --> 00:13:04.180 Yep. 00:13:04.180 --> 00:13:08.780 Until the galectomy happens, which who knows if that will, but until then, this is definitely 00:13:08.780 --> 00:13:09.740 a good introduction to it. 00:13:09.740 --> 00:13:09.980 Yeah. 00:13:09.980 --> 00:13:13.680 And I'm actually, I'm one of the, I don't know, I think there's probably a lot of people, 00:13:13.680 --> 00:13:16.500 but having the GIL doesn't really bother me. 00:13:16.500 --> 00:13:19.060 It does simplify how you program. 00:13:19.060 --> 00:13:20.580 I don't think it's that terrible. 00:13:20.580 --> 00:13:20.980 So. 00:13:21.080 --> 00:13:21.240 Yeah. 00:13:21.240 --> 00:13:21.260 Yeah. 00:13:21.260 --> 00:13:23.300 It's, you know, it's in the extreme cases. 00:13:23.300 --> 00:13:28.020 I think the main group of people who suffer under the GIL are those doing computational, 00:13:28.020 --> 00:13:30.020 CPU computational work. 00:13:30.020 --> 00:13:32.960 Outside of that, you're mostly okay. 00:13:32.960 --> 00:13:33.600 Okay. 00:13:33.600 --> 00:13:33.920 Yeah. 00:13:34.040 --> 00:13:39.020 So in that, like async and await and stuff like that, I'm going to expose my, unknowledge 00:13:39.020 --> 00:13:44.620 of this stuff is, so async and await, is that dealt with, with, multiple threads 00:13:44.620 --> 00:13:44.860 then? 00:13:44.860 --> 00:13:53.380 No, it's all one thread, but it has a mechanism to say, anytime you hit blocking I.O., go put 00:13:53.380 --> 00:13:59.860 this part of the code to sleep and allow it to run another, another task, another thing until 00:13:59.860 --> 00:14:01.700 it hits blocking I.O. 00:14:01.700 --> 00:14:06.020 And the idea is like most of the time you're waiting on databases or networks or something 00:14:06.020 --> 00:14:06.540 like that. 00:14:06.540 --> 00:14:09.400 And then you wake up for a second, you do a little processing and then you go back to wait 00:14:09.400 --> 00:14:12.280 on another network or database or web service. 00:14:12.280 --> 00:14:16.680 And as long as that's the kind of stuff you're waiting on, the GIL is not a problem because 00:14:16.680 --> 00:14:17.340 it gets released. 00:14:17.340 --> 00:14:22.440 But if you're like trying to compute pi with a, you know, power series or something, something 00:14:22.440 --> 00:14:24.640 like that, then it would just, it would stop. 00:14:24.640 --> 00:14:25.940 And the async wouldn't help you with that. 00:14:25.940 --> 00:14:26.160 Yeah. 00:14:26.160 --> 00:14:31.520 I just wanted to, so the async and await is going to use, it's going to be in the 00:14:31.520 --> 00:14:34.680 same sort of a family as when threads would be good for you. 00:14:34.680 --> 00:14:34.900 Yes. 00:14:34.900 --> 00:14:35.180 Yeah. 00:14:35.180 --> 00:14:37.340 It's in exactly this similar spot. 00:14:37.340 --> 00:14:37.560 Yeah. 00:14:37.560 --> 00:14:38.580 But just more efficiently. 00:14:38.580 --> 00:14:41.540 So let's talk about another low level thing. 00:14:41.540 --> 00:14:46.320 And I found this, I think it maybe even was recommended by a listener, some low level 00:14:46.320 --> 00:14:47.020 part of it. 00:14:47.020 --> 00:14:49.080 And then I found the whole, whole thing. 00:14:49.080 --> 00:14:53.760 One of the problems that we can have when we're doing unit testing is working with files, 00:14:53.760 --> 00:14:53.960 right? 00:14:53.960 --> 00:14:55.040 That can be a serious pain. 00:14:55.040 --> 00:14:55.480 Yeah. 00:14:55.480 --> 00:14:55.520 Yeah. 00:14:55.520 --> 00:15:02.020 And if you want to save your files to like say user storage, or you want to process different 00:15:02.020 --> 00:15:07.400 types of files, like zip files, regular, regular files, these are all sorts of pains that you 00:15:07.400 --> 00:15:08.100 have to deal with. 00:15:08.260 --> 00:15:13.400 But there's this really cool project called alternative file systems for Python that makes 00:15:13.400 --> 00:15:14.860 this all seamless. 00:15:14.860 --> 00:15:21.460 So the idea is you can work with files and directories in like zip archives, in memory, 00:15:21.460 --> 00:15:24.880 on the cloud, or just as easy as if they're on your hard drive. 00:15:24.880 --> 00:15:30.480 So they give some examples in this project saying you could write your code now just with open, 00:15:30.480 --> 00:15:34.580 you know, such and such as fin and start working with it. 00:15:34.640 --> 00:15:36.620 And then you decide what that open means. 00:15:36.620 --> 00:15:38.480 Does that open mean normal files? 00:15:38.480 --> 00:15:40.600 Does that open mean something on S3? 00:15:40.600 --> 00:15:41.640 Things like that. 00:15:41.640 --> 00:15:43.740 You can unit test your code. 00:15:43.740 --> 00:15:48.340 You can just have in-memory files, but open reads and writes to those in-memory files. 00:15:48.340 --> 00:15:55.820 You can upload your files to like S3 or OneDrive or something like that by just writing to that 00:15:55.820 --> 00:15:59.280 folder, you know, in that file system and all sorts of stuff like that. 00:15:59.280 --> 00:15:59.560 Yeah. 00:15:59.560 --> 00:16:04.240 So the, like the memory file system or the temporary file system that they have would be great for 00:16:04.240 --> 00:16:06.880 like parallelizing tests and things like that. 00:16:06.880 --> 00:16:07.120 Right. 00:16:07.120 --> 00:16:08.640 It keeps it all separate and isolated. 00:16:08.640 --> 00:16:12.340 So some of the back ends they have is they have application data. 00:16:12.340 --> 00:16:16.040 This is like the special user data locations in various operating systems. 00:16:16.040 --> 00:16:19.160 They have Amazon S3 file systems. 00:16:19.160 --> 00:16:21.440 They have FTP memory. 00:16:21.440 --> 00:16:22.660 Let's see what else. 00:16:22.660 --> 00:16:23.500 That's pretty cool. 00:16:23.500 --> 00:16:26.900 They've got zip for reading and writing zip files. 00:16:26.900 --> 00:16:32.140 And they also have like SSH file systems for writing to remote servers, all kinds of stuff. 00:16:32.380 --> 00:16:34.040 And even tar files. 00:16:34.040 --> 00:16:35.060 Good old tar files. 00:16:35.060 --> 00:16:36.140 Good old tar files. 00:16:36.140 --> 00:16:36.420 Yeah. 00:16:36.420 --> 00:16:38.000 You can just whiff open on those babies. 00:16:38.000 --> 00:16:38.560 Yeah. 00:16:38.560 --> 00:16:43.580 So this is really pretty interesting and I haven't tried it yet, but it looks, it looks quite promising 00:16:43.580 --> 00:16:44.420 and it's extensible. 00:16:44.420 --> 00:16:47.200 So you can add more of these back ends if that makes sense for you. 00:16:47.280 --> 00:16:47.920 That's awesome. 00:16:47.920 --> 00:16:49.900 I actually think this is pretty fun. 00:16:49.900 --> 00:16:50.680 I got to play with this. 00:16:50.680 --> 00:16:50.920 Yeah. 00:16:50.920 --> 00:16:51.300 Yeah. 00:16:51.300 --> 00:16:51.460 Yeah. 00:16:51.460 --> 00:16:51.820 Me too. 00:16:51.820 --> 00:16:53.540 So definitely check that out. 00:16:53.540 --> 00:16:56.220 And Brian, that's it for our six items for the week. 00:16:56.220 --> 00:16:58.700 That's incredible that we've already done. 00:16:58.700 --> 00:16:59.420 So. 00:16:59.420 --> 00:17:02.580 I know these are, they're all fun and all interesting. 00:17:02.580 --> 00:17:05.060 I really enjoyed researching them this week. 00:17:05.200 --> 00:17:06.640 So what else are you up to? 00:17:06.640 --> 00:17:12.900 I got an interesting email this morning saying that they've taken off the beta off of the 00:17:12.900 --> 00:17:16.700 Python testing with pytest on the Pragmatic website. 00:17:16.700 --> 00:17:21.220 And you can order the book now and it's supposed to ship next Monday. 00:17:21.220 --> 00:17:22.240 That is awesome. 00:17:22.240 --> 00:17:23.220 Congratulations. 00:17:23.220 --> 00:17:23.820 Yeah. 00:17:23.820 --> 00:17:24.240 Thanks. 00:17:24.240 --> 00:17:26.980 So that is what I've been thinking about. 00:17:26.980 --> 00:17:27.660 I bet. 00:17:27.660 --> 00:17:28.000 Nice. 00:17:28.060 --> 00:17:29.100 I've been thinking about switch. 00:17:29.100 --> 00:17:32.360 Well, I have been too as of this afternoon. 00:17:32.360 --> 00:17:32.860 So. 00:17:32.860 --> 00:17:38.880 I'm working on a project that would add the switch statement to the Python language without 00:17:38.880 --> 00:17:39.580 extending it. 00:17:39.580 --> 00:17:41.760 Just like a class that you can basically use. 00:17:41.760 --> 00:17:45.160 But it's a pretty clever use of like defining blocks and stuff. 00:17:45.160 --> 00:17:46.900 And I think it might be interesting. 00:17:46.900 --> 00:17:51.280 I'll put a link to a gist or a GitHub repo or something for you at the end of the show notes. 00:17:51.280 --> 00:17:52.360 And you guys let us know. 00:17:52.360 --> 00:17:55.780 I really do want feedback on that because I want to try to nail this. 00:17:55.860 --> 00:18:00.820 And I think if we could get it into something, we could stick on PyPI or have you do the 00:18:00.820 --> 00:18:01.380 work actually. 00:18:01.380 --> 00:18:02.360 Pip install switch. 00:18:02.360 --> 00:18:03.060 There you go. 00:18:03.060 --> 00:18:04.140 That might be a thing. 00:18:04.140 --> 00:18:04.700 Don't do that. 00:18:04.700 --> 00:18:05.240 Yeah. 00:18:05.240 --> 00:18:05.880 Don't do that. 00:18:05.880 --> 00:18:07.300 Switch laying. 00:18:07.300 --> 00:18:07.720 Who knows? 00:18:07.720 --> 00:18:11.980 But yeah, I think it would be a really cool feature if we could make it work for the language 00:18:11.980 --> 00:18:15.140 without actually changing the language because it's already flexible enough. 00:18:15.140 --> 00:18:15.560 Yeah. 00:18:15.560 --> 00:18:16.040 Cool. 00:18:16.040 --> 00:18:16.460 Cool. 00:18:16.460 --> 00:18:17.000 All right. 00:18:17.000 --> 00:18:19.760 Well, thanks for everything, Brian. 00:18:19.760 --> 00:18:21.240 And good to talk with everyone. 00:18:21.240 --> 00:18:24.480 Thank you for listening to Python Bytes. 00:18:24.620 --> 00:18:27.040 Follow the show on Twitter via at Python Bytes. 00:18:27.040 --> 00:18:29.940 That's Python Bytes as in B-Y-T-E-S. 00:18:29.940 --> 00:18:33.360 And get the full show notes at pythonbytes.fm. 00:18:33.360 --> 00:18:37.700 If you have a news item you want featured, just visit pythonbytes.fm and send it our way. 00:18:37.700 --> 00:18:40.400 We're always on the lookout for sharing something cool. 00:18:40.400 --> 00:18:43.800 On behalf of myself and Brian Okken, this is Michael Kennedy. 00:18:43.800 --> 00:18:47.400 Thank you for listening and sharing this podcast with your friends and colleagues.