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


Transcript #348: JavaScript in Your Python

Return to episode page view on github
Recorded on Tuesday, Aug 15, 2023.

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

00:05 This is episode 348, recorded August 15th, 2023.

00:09 I'm Michael Kennedy.

00:11 And I'm Brian Okken.

00:12 And Brian, this episode is brought to everybody by us.

00:15 I think you might be making a more concrete case for that than other times today.

00:21 So, but yeah, check out all of our courses, books, things like that.

00:25 It genuinely makes it possible for us to do this kind of stuff.

00:28 Yeah, we love doing it, but yeah, also.

00:32 Yeah, yeah, also.

00:33 And if you want to be part of the live show and you're not watching live now, Tuesdays at 11,

00:39 I go by set.fm slash live, all the details there.

00:42 Brian, let's kick it off.

00:43 What's your first item?

00:44 Actually, I'm kind of on a packaging, a little bit of a packaging thing today.

00:49 Okay, okay.

00:50 Brett Cannon wrote an article called Differentiating Between Writing Down Dependencies to Use Packages

00:56 and for Packages Themselves.

00:58 It's kind of a big title.

01:00 But here's the idea.

01:01 And I've been thinking about this also.

01:03 So I really, there's requirements.txt files.

01:06 And those are often used for applications.

01:09 And then there's, but that was really when we had like, that was either that or setup.py for packages.

01:16 And now we have pyproject.toml.

01:18 So can't we just use that?

01:20 I mean, I kind of want to, but it doesn't quite work that way.

01:24 You install dependencies with a pyproject.toml by doing a pip installing your package.

01:30 And you can install it like pip install.e.

01:34 I think, yeah, pip install.e.

01:36 dash e, right.

01:38 And on the current directory, or you can give it a local project directory.

01:42 And you can even do optional things like optional test dependencies and stuff.

01:47 And I think when you do the dash e, it installs your optional test dependencies also.

01:54 I'm not sure.

01:54 But, and I'm used to that because I do packages also.

01:57 But we still have the requirements.txt file.

02:00 There really are for different things.

02:02 So Brett has talks about this a lot in here.

02:06 And looking at why there's a thing called like project dependencies.

02:11 And the project is really meant for packaging.

02:15 It's really meant just for the whole packaging system.

02:18 So that when you install something, install a wheel, it knows how to get packages for it.

02:26 That's it.

02:26 It's not supposed to be for applications.

02:28 So really, that's kind of the discussion around here, around this article.

02:33 However, there's a couple ideas.

02:35 He references, also references back a Donald Stuffed article from 2013 about setup.py versus requirements.txt.

02:45 But like I said, that was setup.py.

02:47 Maybe we could do something better.

02:50 Brett's consideration is maybe we could have some standard, something, some other file that we could have.

02:59 I personally, I think that maybe we could expand PyProject.toml.

03:05 I really like the Toml thing.

03:07 So maybe we could either have a requirements.toml, or maybe we could have like instead of a project section of the Toml file,

03:15 maybe we could have maybe an application section.

03:18 Maybe that would work.

03:20 Yeah.

03:20 So yeah, I think like a dev requirements even just in the PyProject.toml

03:25 seems pretty straightforward to me.

03:27 Yeah.

03:27 I mean, I run into it in other places too, like just in a Git repo that has like a couple Python

03:35 tools in it that people can install on their own.

03:38 But they might have some requirements.

03:40 How do you list those?

03:41 Do you stick them as applications?

03:42 I mean, requirements.txt is normally the thing that's used for like Django web applications and

03:50 things like that.

03:51 So maybe requirements.txt is fine, but I think.

03:55 Perhaps.

03:55 What I have is I have for my world, I have requirements.txt, which is like from the web apps and stuff.

04:01 That is what is required for the app to run without that.

04:05 Yeah.

04:05 You can't make it go.

04:06 Then I have requirements-dev.txt.

04:09 I've seen that pattern a lot.

04:10 And then to actually generate those, I use pip-tools and pip compile.

04:14 So I have requirements.in and requirements-dev.in.

04:17 And then I can auto-update all the dependencies and keep them in sync.

04:21 Yeah.

04:22 That's how I do it these days.

04:23 But now even people with Django or other things are using a PyProjectTunnel also to store their

04:33 black settings and things like that.

04:35 So we're kind of using the PyProjectTunnel for more things.

04:41 And I think maybe we could extend it for this.

04:43 Anyway, that's my hope.

04:44 It seems reasonable.

04:45 Yeah.

04:45 So anyway, what do you got for us?

04:48 Well, let's monkey around a little bit with the Python monkey.

04:51 With the Python monkey.

04:52 That's cute.

04:53 That's cute.

04:54 It is.

04:54 So this comes to us from created by Will Pringle, I believe, amongst others.

05:00 Let's see.

05:01 On the contributors here.

05:03 There.

05:05 Yeah.

05:06 There we go.

05:06 Yeah.

05:07 So a bunch of folks that work on this project.

05:09 It's not super popular with only 276 stars, but I think it might be a pretty darn interesting

05:15 compatibility layer for Python.

05:18 So what do I mean by that?

05:19 So imagine I'm, you can look at this from two perspectives.

05:24 So don't scoff at one if you prefer the other.

05:26 So imagine I'm a JavaScript developer and I've got a ton of cool JavaScript code that not just for the web front end, but, you know, kind of in the node JS sense, like a bunch of utilities or a bunch of libraries that work and do certain things.

05:41 Right.

05:41 Yeah.

05:42 But I also have a Python app and I'd like to somehow use those together.

05:45 So Python monkey is a straight way to put it.

05:49 It, it basically hosts job, a JavaScript, a full on high performance JavaScript, JIT compiled to almost native performance JavaScript engine inside of Python through pip install.

06:00 So if I wanted to use some of the JavaScript code, I just write my Python application and for that function or that functionality, I just import the job, you know, first spider monkey or Python monkey.

06:15 And then I import the JavaScript files that you would use.

06:20 And then you just call them like Python functions.

06:22 Okay.

06:23 Or reverse, I'm writing a Python application and you know, one option to make like slow loops go faster would be to write that in Cython and Cython is getting better with the Cython three release that we discussed already previous episode.

06:37 But JavaScript, because this thing, the spider monkey JavaScript engine is the one that I believe Firefox uses does JIT compilation to native code.

06:48 It basically is near native performance as well.

06:50 So if you'd like, you could rewrite that part in TypeScript or JavaScript and run just that section.

06:56 And it uses things like shared memory between JavaScript and Python.

07:00 So if you've got like a string or a list, those are, those are the same objects, which is pretty crazy.

07:06 Wow.

07:07 At least for the strings.

07:08 Okay.

07:08 So, let's look at some examples.

07:11 There's an article by will and no, I will not log into medium.

07:14 You're partially evil.

07:15 Okay.

07:16 So here's an article by, my will here says, look at, let's look at some code examples.

07:22 All right.

07:23 So import Python monkey as PM.

07:25 And then you say PM eval and give it JavaScript code and then boom, it runs that.

07:30 That's one way.

07:31 what you can do maybe is more interesting is look at this.

07:33 I can say, em dot eval and give it an anonymous JavaScript function.

07:38 And then what comes back, not evaluating it, but just the thing to define the function in JavaScript.

07:44 Okay.

07:44 And then what comes back is an object that itself is a function.

07:48 Okay.

07:49 So that's pretty cool.

07:50 Yeah.

07:51 like, and hold on.

07:52 There's two parts of this.

07:53 So I've got a, I've created a JavaScript function.

07:56 That's jet compiled in spider monkey through this eval.

08:00 And what the, I didn't say this part, what the function takes is given a function.

08:04 It will call that function passing hello world to it.

08:07 Okay.

08:08 The string hello world.

08:09 Okay.

08:09 So what you do is you get the function back as a Python function and then they pass print.

08:14 It somehow proxies the print function into the JavaScript space.

08:19 And then JavaScript calls the Python print, which it then comes back to the console, to the terminal.

08:24 Wow.

08:25 Oh, okay.

08:26 That's some deep integration, right?

08:27 That's some pretty, pretty wild stuff.

08:29 let's see.

08:31 What else can we do here?

08:32 This is pretty interesting.

08:33 I can say, given a JavaScript module, like I described, I can, you know, here's a example.

08:39 It has a say hello export.

08:41 Then you can just say PM dot require that JavaScript module.

08:45 And now you've got all the function, all the export behavior from that JavaScript module.

08:50 Right.

08:51 Which is cool.

08:52 yeah, there's, there's some more examples in here.

08:55 The other angle that's pretty interesting.

08:57 There's two more angles that are interesting because it uses spider monkey and spider monkey

09:01 is awesome with WebAssembly.

09:03 It allows you to run, untrusted WASM code from languages like C, C++ and rust.

09:09 You can now basically do, any, you can call any WebAssembly code as well that you'd

09:15 like inside of your function.

09:17 Now we're getting interesting.

09:18 Yeah.

09:18 It supports things like async and await using the async and await keywords to handle the

09:23 callback nature of JavaScript.

09:25 like the, the dot then type of deferreds and different things.

09:30 So you can just async and await those behaviors, right?

09:33 Just await a WebAssembly call, which is pretty excellent.

09:36 Yeah.

09:37 So there's a bunch of, examples, some pretty cool graphics here.

09:42 with Spock and, captain Kerr going my mind to your mind, my object, the your dicks, your

09:48 dicks to my objects.

09:50 It's pretty awesome.

09:51 There.

09:51 another angle that is worth considering is this allows the entire Python data science

09:57 stack to become accessible to JavaScript developers.

09:59 developers, right?

10:01 Yeah.

10:01 So if you, if you want to use, you know, the machine learning stuff, if you want to use

10:05 pandas or pollers, right.

10:07 You just write your code and then, you know, do the integration here.

10:11 And yeah, that's, that's pretty much it.

10:13 it, it finishes with, some funny little pictures here of, no on the arc.

10:19 Got a Python and a JavaScript, which looks like a penguin.

10:23 And then it has the Python monkey.

10:24 The what, what is that?

10:25 What the heck is this?

10:26 All right.

10:26 Anyway, that's, that's Python monkey, which is, I think, potentially interesting.

10:33 So with the, with the WebAssembly and stuff, you could potentially have like every other

10:38 function in your system be implemented by a different language.

10:42 I'm bored of, C, C++ rust go.

10:49 what else do we want to write it in?

10:51 Yeah.

10:51 Why not everything?

10:52 just make sure that your, your application is only maintainable by you.

10:56 That'd be.

10:57 Exactly.

10:57 Like, do you know how many compilers you need to do this?

10:59 No, this is a mall.

11:00 That's kind of fun to, to joke about, but this does look pretty cool.

11:03 So yeah.

11:04 Yeah, it does look pretty cool.

11:06 So, you know, congrats to the folks there.

11:08 This maybe it'll go somewhere.

11:10 We'll see.

11:10 It's, it's pretty interesting.

11:11 I think, also it's, it's worth noting, that there is, somewhere in here that there's

11:18 a comparison to other things.

11:19 So this apparently is not the only time such a type of creation, has been attempted.

11:25 So it says there are other projects that already do JavaScript and Python, such as JS to PI,

11:29 PI V8 and medical.

11:31 But there's a bunch of different drawbacks or stuff.

11:33 And so this is why we created it basically in addition.

11:36 So JS to PI is implemented entirely in Python, which sounds awesome, except, you know, V8 and

11:42 spider monkey compiled a native code and run ultra fast.

11:45 Whereas, you know, if you just run in Python, it probably doesn't have any of those things.

11:48 Right.

11:49 PI V8, has a wrapper around Google's V8 JavaScript engine, which is great, but it's just super low level.

11:56 You just like talk directly to the JavaScript bits, which for things, for example, doesn't have async and await.

12:02 And finally medical is extensible, embeddable and interoperable, but you've got to install a bunch of different run times outside of just pip install.

12:10 So anyway, if people are going, but it exists, it does, but this apparently is why it exists like this.

12:16 Yep.

12:17 Cool.

12:17 Yeah.

12:18 And John out in the audience says, I, I do this, but going the other way using transcript.

12:22 Okay.

12:23 Interesting.

12:24 Something else to, something new to check out.

12:26 Thanks, John.

12:27 We'll take that out.

12:28 So.

12:28 All right.

12:29 Over to you, Brian.

12:30 well, I just, one more thing, Olivero, says, Python monkey perfect for works on my machine certification.

12:38 There, there is an official works on my machine certification.

12:40 If you have, I know we talked about it before.

12:42 It's glorious.

12:43 It comes with a sticker.

12:44 Power your application code, getting the latest version of any recent changes from other developers, purely optional and not a requirement for certification.

12:53 Launch the application cause one code path in the code you're checking to be executed.

12:58 The preferred way to do this is with ad hoc manual testing.

13:00 You can omit this step.

13:02 If the code change is less than five lines, or if in the developer's professional opinion, the code could not possibly result in an error.

13:08 Check your code into version control.

13:10 You're certified.

13:11 Yeah.

13:13 There we go.

13:13 Two jokes in one episode.

13:14 How that, how about that?

13:15 Awesome.

13:16 Well, we had a little bit more, some, a little more humor, to add to it.

13:21 So because, I thought it was a serious article and it is, it's just funny and weird.

13:26 So Seth Larson wrote, quirks of Python packaging, versioning package, Python package versioning.

13:33 That's it.

13:34 so we're used to, well, we're kind of getting used to, the world where we all have some ver like 1.2.3 and for semantic versioning, but we also have calendar versioning like 2023.6.1.

13:48 And then there's stuff like you can add a pre-release suffix and things like that, but it gets way weirder and fun.

13:55 so, and I have noticed this, especially with get up, like get get up versioning.

14:01 Sometimes people will do, V versioning.

14:04 So there's V prefixes you can do.

14:06 And some, I guess you can pull that into your, your Python application version as well.

14:12 Why not?

14:13 so V versions are allowed, epic versions.

14:17 Did you know about epic versions?

14:18 I just learned about this.

14:19 I don't think so.

14:21 So it's, you can, you can have a, a exclamation point separating your epic from the rest of your version.

14:30 So this is, so like one bang 2.0.0 would be epic one version 2.0.0.

14:38 I got to tell you, I already had a hard time deciding when the two or when the middle zero or the last zero changes.

14:43 If I put a number in front of an exclamation point, I'm going to just lost.

14:47 Yeah.

14:47 Apparently.

14:48 Too much decision.

14:49 Too many decisions.

14:50 Apparently some systems use colons for epics, but Python chose, this is all based on Python

14:55 PEP 440.

14:56 and, the, yeah, apparently we chose the bang symbol or is that spang, right?

15:03 the exclamation point.

15:05 so, and that just kind of looks like a one.

15:08 If you did one bang one, that would be hard to tell.

15:10 local versions.

15:12 and is you can, you can extend after you have versions, you're going to have alpha

15:17 numerics and, other stuff.

15:20 like, you know, here, plus, I don't know if the plus is part of it anyway.

15:24 so after your normal version, like 1.0.0, he has an example of plus Ubuntu dash one.

15:30 this gets normalized, but, but, and luckily, but this is kind of nice for local

15:37 it's local versions because pipe AI doesn't like it.

15:40 So pipe AI will not let you push up local versions to guy, which is probably right.

15:45 local builds, long versions.

15:49 Apparently you can use the, use the first 217 digits of PI and that works fine.

15:54 as, as one of the digits, there's no limits, case insensitivity.

16:00 so yeah.

16:02 Okay.

16:02 That's fine.

16:03 it gets normalized lower or something so that you, you know, capital RC one is the

16:10 same as lowercase RC one.

16:12 That's, that's appropriate.

16:13 so pre-release I've seen, I've actually used pre post.

16:17 I don't know if I use pre I've seen pre and I've used post release occasionally, although

16:22 it's so weird that people don't understand what's going on.

16:25 So I don't do that anymore.

16:27 but apparently pre post and dev are not mutually exclusive.

16:31 You can have, but all three, allowed in one version.

16:35 Why would you do that?

16:37 so, and, yeah, no delimiters needed.

16:41 there's just a lot of fun here.

16:44 thanks.

16:45 So implicit hyphens are allowed.

16:47 So this is both the serious and non-serious.

16:50 Oh, implicit zeros are weird.

16:52 So, you can, you can, if you have a version 2.0.4, you can just keep adding a bunch of 0.0.0.0

17:01 and it works fine.

17:03 It resolves to 2.0.4.

17:05 That's awesome.

17:05 I, I, I definitely need to advertise some version say, just, just pick up 2.0.3.

17:13 0.0.0.0.

17:15 Yeah.

17:17 It looks, makes it sound tough.

17:18 Like, yeah.

17:19 I mean, in releases we've had.

17:20 Anyway, totally, totally fun articles.

17:24 So thanks, Seth.

17:24 Brian, do you hear that?

17:25 No.

17:26 That's the sound of a million regexes dying.

17:29 That are supposed to be scanning for the version string in your code.

17:35 Yeah.

17:36 But maybe that's why Python just has it as a string.

17:40 It's, if you do dunder version equals, it's, just a string.

17:44 So.

17:44 Yeah.

17:46 Axel asks, if you use C++ compiled code, so I guess native code, that's like not part

17:51 of just source only Python.

17:53 Is there a way to define which compiler you use in the versioning?

17:56 Maybe that Ubuntu type variant, that local version, but you can't publish that, right?

18:01 you can't push it to PyPI like that.

18:04 But like, for instance, it's a, I'm not sure how this, this relates to, like

18:10 the wheel naming, the wheel download naming thing.

18:13 Yeah.

18:13 so.

18:15 I'm sure there's some metadata you could put in there, right?

18:18 Like you can do dunder version, right?

18:20 You could just do dunder compiler and say, you know, print that out and it'll tell you,

18:23 but it's not, there's no standard that I can think of.

18:26 Well, there's the, there is the, the wheel standard.

18:29 I just don't remember where the link is.

18:31 But that's more platform based, right?

18:33 Than a compiler.

18:34 Oh, right.

18:35 It's not compiler based.

18:36 It's platform based.

18:37 I mean, the compilers got to compile to the platform, but it, it doesn't say like use GCC

18:41 versus LLVM, Clang, Visual Studio, whatever, right?

18:45 Right.

18:46 Yeah.

18:46 And usually I'm just doing pure Python.

18:48 So I have all listed, but the wheel, anyway.

18:51 Exactly.

18:52 So.

18:52 Exactly.

18:53 All right.

18:54 Well, with all that, Python monkeying around, I could just barely stand it.

18:59 Oh dear.

19:00 About bear type.

19:01 Nice.

19:02 The bear metal type checker.

19:04 Okay.

19:04 So people know I'm a huge fan of types, Python type hints and all those things.

19:08 They're, they're super, super empowering and make the editors so much more helpful.

19:13 It means you don't have to go into, the documentation and go, what does this take again?

19:18 I know it takes an, an ARGs here, but is ARGs a dictionary?

19:21 Is it a class?

19:22 Is it a string?

19:23 Is it an, I, what is it?

19:24 Right?

19:25 Like crazy stuff like that.

19:26 Right?

19:26 Yeah.

19:26 So types are awesome for conveying that information without asking go to the docs or some other

19:31 place to figure it out.

19:33 However, what Python type hints, annotations generally don't do as the word hint would indicate.

19:42 You can use tools like my PI and my PI will say the typing looks consistent or inconsistent,

19:48 but regardless of what it says, when you run the code, whether or not the typing is consistent,

19:52 long as it actually still semantically valid, it's going to run.

19:56 Even if you tell the types, it takes a string, but you really pass an int and it did plus to

20:01 it, but you know what?

20:02 You pass two integers and two strings and it still worked.

20:04 Right?

20:05 So the runtime version of typing and Python is mostly absent, right?

20:09 Excluding things like Pydantic and a few others.

20:12 So this bear type thing is a near zero cost, near real time, pure Python runtime type checker

20:19 that makes runtime mismatches for typing runtime errors.

20:25 Interesting.

20:26 Okay.

20:26 So you can say, this sounds like a horrible idea and I will never touch it.

20:30 Please don't, you know, install the bear.

20:32 Or you could say, I come from a static language and this dynamic typing business is freaking me

20:38 out.

20:38 Can we get a little closer?

20:39 Then you can have it.

20:40 I feel like this is the kind of thing that for little projects is completely useless,

20:43 but for huge projects, it may be, it starts to become more valuable.

20:47 Right?

20:47 Yeah.

20:48 So if you just jump right into it, you pip install bear type, and then you can do things

20:53 like, import the decorator and just put a decorator onto a function that has a type

20:59 annotation or hint right there like that.

21:01 So here's one that says quote Wiggum and then it passes lines in the type declaration says

21:07 lines is a list of stir and it returns none.

21:10 Okay.

21:11 Okay.

21:11 So then if you just use this function, pass it a list of strings, it just runs.

21:16 Right?

21:16 Yeah.

21:16 If however, though you pass it a list of bytes, which kind of look like strings, but are not

21:22 strings, you get an exception that says parameter such and such and such.

21:27 it gives you the actual index in the list.

21:32 It says list item zero with this value is not a string.

21:36 Cause it's a B string, which is really bytes, right?

21:38 Yeah.

21:39 It's pretty cool, right?

21:40 Yeah, it is really cool.

21:42 and I, I'm kind of, agreeing with, Alvaro, said, maybe, maybe running with the test suite.

21:51 And I was thinking maybe dynamically add these somehow, use the bare types during

21:57 development and maybe, maybe take them off later if it, but if it's really fast,

22:02 yeah.

22:03 Yeah, I'll, I'll comment on that in a second.

22:05 there are also validators.

22:08 There's an is and an annotated validator.

22:10 If you want to be more restrictive, maybe even then you might expect it's part of Python, but

22:16 it's not a commonly known part of the type and then thing.

22:19 So for example, I could define a new type using annotated called list of strings.

22:25 Okay.

22:26 And it says, it has to be a list of strings as one part of the annotation.

22:31 And then another one is, well, if it's, it has to be a non-empty set of strings is what

22:37 they're trying to create here.

22:38 Okay.

22:39 So it says if it's a list with a bunch of stuff, the bunch of stuff has to be strings,

22:43 but it also contests that it's not falsy, which would be the case when it's a just, you

22:49 know, zero length list.

22:51 So then you can annotate with that type.

22:54 And if you call with regular somewhere, you call it with a regular code is fine.

22:58 But if you call it with the empty list, where it says a list of strings, it says, no, no,

23:02 no, it can't be an empty list.

23:03 It has to be a non-empty list of strings.

23:05 So there's like some pretty crazy things that you can, can do here.

23:09 yeah.

23:11 Some other stuff you can check if you'd like, but yeah, it's, I wanted to read this, this

23:16 introduction article here, which actually comes after all the examples.

23:19 by the way, it also, in order to run this whole bunch of times, it took 33 microseconds,

23:27 which is pretty incredible.

23:29 The test, test this for like an array of tuples of arrays of what is that?

23:36 A million, you know, 33 microseconds.

23:38 So that's pretty fast actually.

23:39 Yeah.

23:39 You still want to like compare it like your entire, like some workflow compared to with

23:44 or without.

23:45 So.

23:45 Yep.

23:46 So let me read this.

23:47 So if people are wondering, what the heck is this?

23:49 Bear type brings Rust and C++ inspired zero cost abstractions into the lawless world of dynamic

23:55 typing, dynamically typed Python by enforcing type safety at the granular level of functions

24:01 and methods against type hints standardized by the Python community.

24:04 And oh, one non amortized worst case time with negligible constant factors.

24:09 How about that?

24:10 So if anyone asks what bear type is, there's a good description.

24:12 Yeah.

24:14 Well, yeah, it's, it's pretty cool.

24:16 And then there's a whole bunch of stuff about it, but anyway, that that's bear type.

24:19 It looks pretty promising to me.

24:20 Like the drawback of a lot of these think really is like, well, now you're doing a bunch of checking

24:25 for every little function call and it's super slow, but if it's fast enough, that's, that's

24:29 pretty cool.

24:30 Yeah.

24:30 So a couple of comments in the chat.

24:32 Mike Felder doesn't Pydantic include call validators too.

24:39 So I'm not sure how that relates.

24:40 I don't know if that's out of beta.

24:42 Last time I looked at it, it was still in like a testing phase.

24:46 It may be out there.

24:47 I mean, there's a ton of work that's happened on Pydantic.

24:50 It's all been redone.

24:51 So I don't know the status of that.

24:53 Maybe Mike does.

24:53 Okay.

24:54 And then also, is there a mypy plugin that does that?

24:57 I don't, I don't, I wasn't aware that mypy could be used at runtime, but.

25:01 I wasn't aware mypy could be used at runtime either, but perhaps.

25:05 Yeah.

25:06 Anyway.

25:06 But anyway, this, this looks pretty, you know, quite straightforward, pretty useful.

25:10 You just do type ins, you put app bear type on it and it, it makes sure that it behaves.

25:14 Yeah.

25:14 So to do what you were looking at, sorry, to do where you might want to turn it off in production,

25:19 but run it in testing, which is reasonable.

25:21 I don't see any mechanism for that.

25:23 There may be.

25:24 Yeah.

25:25 But it's a, it's a decorator mechanism.

25:27 So you could, you could work around it if you needed to.

25:29 Well, you could just write a decorator that looks whether that setting is on or off and

25:35 either returns the bear type wrap thing or the direct function directly.

25:39 And it would be like zero runtime cost once it's turned off because the function is replaced

25:43 with itself.

25:44 Yeah.

25:44 Otherwise it's replaced by the bear type decorated one.

25:47 Right.

25:47 So you could, you might have to write like 10 lines of Python.

25:50 Yeah.

25:51 Then you've got that feature, right?

25:52 The other thing is how much of your code are you really going to want to throw bear type

25:57 decorators around all over the place?

25:58 Yeah.

25:59 That's a good point.

26:00 Maybe just the boundary, right?

26:01 Yeah.

26:01 At the API level or something.

26:03 Yeah.

26:03 Exactly.

26:04 Exactly.

26:04 Yeah.

26:05 Cool.

26:06 Yep.

26:06 Anyway, there it is.

26:07 And I suppose that's it for all of our items.

26:10 That's what we got lined up for you.

26:12 Anything else?

26:12 Some extras.

26:13 I have.

26:14 You want me to go first?

26:15 You want to save yours?

26:15 Yeah.

26:16 You go first.

26:17 All right.

26:17 I already got my screen up anyway.

26:18 Okay.

26:19 So first of all, congratulations, Mike Falder, who is right here in the audience.

26:26 Yeah.

26:27 And I mispronounced his last name.

26:28 Sorry.

26:29 Hopefully I got it right.

26:31 You did.

26:31 I got it right.

26:32 At Mike the man on Twitter is the new safety and security engineer for PyPI.

26:39 That's awesome, Mike.

26:41 Thank you so much.

26:42 Cool.

26:42 Clearly an area that needs lots of attention.

26:45 So I just wanted to say welcome.

26:47 Thanks for keeping us all safe out there.

26:49 And excellent.

26:51 Yeah.

26:51 I got to hang out with Mike a lot at PyCon.

26:53 So that's really pretty cool.

26:55 Yeah.

26:55 Thanks.

26:56 Super cool.

26:56 Super cool.

26:57 And then a couple of quick announcements, two conferences for people.

27:00 Packaging Con, follow up on all of your items, Brian.

27:03 Packaging Con.

27:04 Cool.

27:05 Is happening fully online.

27:07 No, hold on.

27:08 No.

27:09 It's happening in Berlin as hybrid.

27:10 So it's in Berlin, October 26 to 28 for all things packaging, Python people, Rust people,

27:18 et cetera.

27:18 So check that out.

27:20 And the Cloud Builders Python Conf is September 6, 2023.

27:24 That's put together by a Ukrainian group.

27:27 And it's just online.

27:28 So people can check that out as well.

27:30 And speakers, are they still have a call for proposals?

27:34 Doesn't look like it.

27:35 I think it's open.

27:36 It's already all set for the agenda.

27:39 So people can check that out.

27:40 It should be fun.

27:41 And on to your big news.

27:43 Okay.

27:43 Well, a couple, just a couple notes that I wanted to mention.

27:48 The August release of Visual Studio Code has something I've been long awaiting.

27:54 It's an error tolerant pytest discovery.

27:56 So what does this mean?

27:58 It means you've got, and there's like some comments down here.

28:01 Oh, I went too far.

28:03 You have to turn it on right now.

28:05 But it's just in a setting.

28:06 Apparently, some people have it on by default.

28:09 Anyway, they should just turn it on.

28:11 It's better.

28:11 But the gist is, if you've got like errors in some of your code, it used to not.

28:18 It used to just blow up.

28:19 Like, let's say you've got a test suite.

28:21 But you also have like some old junk tests off in a side directory that you don't use anymore.

28:26 If they had import errors or syntax errors or whatever, it would just blow up the whole thing and you couldn't get any tests to import.

28:32 Now, it's tolerant and it just turns off the, it doesn't, it doesn't import those tests that have import errors.

28:39 That's great.

28:40 So you can still run the rest of the suite.

28:41 So that's good.

28:42 Be kind of still kind of cool.

28:45 There's a couple of things.

28:45 Be kind of cool if it could tell you which ones have had errors instead of just making them disappear.

28:51 So that'd be neat.

28:52 The other thing is, guys, pytest isn't capitalized.

28:55 So you've got to work on your capitalization, non-capitalization.

28:59 But discovery probably should be.

29:01 Oh, yeah.

29:02 Oh, yeah.

29:03 Discovery should be.

29:04 Oh.

29:04 That's all right.

29:05 That's tough.

29:06 Anyway.

29:07 I always, I'm always unsure about my capitalization.

29:10 It's so formal to capitalize everything.

29:13 It's this time of year again, we got Python 3.12, release candidate 1.

29:20 So we're in the release candidates for Python 3.12.

29:24 It's pretty exciting.

29:24 Release candidate is a big deal, though, right?

29:27 It's, we think this is the final version unless there's something gone wrong.

29:31 Yeah.

29:31 It's right out of beta.

29:34 So anyway, speaking of beta, the big news for today is that I've got a Python testing with pytest bundle course up.

29:44 And I'm super excited about it.

29:47 I'm working really hard.

29:48 However, it is in pre-release, pre-release beta.

29:54 I don't know.

29:55 I made up something that.

29:56 Early bird.

29:57 Early bird sort of.

29:58 Early beta bird.

30:00 Yeah.

30:00 So what is going on?

30:02 So there's, in the end, it's going to be, actually, I wrote it.

30:07 I included on here is a video that is got like, welcome to the pre-release beta.

30:13 And what does that mean?

30:14 Video.

30:14 So you can watch that.

30:15 The gist of it is, is the three sections of the book are going to go into three different courses.

30:21 But the pre-release right now that's for sale is a bundle of all that will be all three.

30:28 There's two chapters ready for, for the primary power for the first part.

30:33 And, but I'm just going to chug along and people can jump in if they want.

30:37 I'm, I'm doing it as a beta because the book itself really is better because of the beta program that I did when I was writing the book.

30:45 And I'd love to have people come in and let me know where things need a little polish and we can, you know, we can fix it along the way.

30:54 I also am setting up a job or not a job board, a discussion board for people to ask questions if they get stuck.

31:02 I really want to make sure everybody's successful in getting, getting this up and running, getting up and running and py test quickly.

31:08 So totally excited about getting this done.

31:11 Oh, one more thing I set up, I just, just launched it last night, but, for Python bytes listeners, you can use the coupon code Python bytes with a Y.

31:23 So, and, he, we'll just throw that in the show notes, use Python bytes, with a Y and you can get 20% discount now through the end of the 17th.

31:34 So just a few days.

31:36 but, that's enough time to grab it.

31:39 So cool.

31:39 Yeah.

31:40 Awesome.

31:40 Congrats on this, Brian.

31:41 And this will be exciting.

31:42 And I know it's a lot of work, so.

31:44 Yeah.

31:45 Good luck.

31:46 Thanks.

31:46 Yeah, absolutely.

31:48 Oh, you know what else is a lot of work and ties back to my first item, learning JavaScript.

31:53 Let's make that our joke.

31:54 Okay.

31:55 All right.

31:56 So here's the text.

31:57 It looks like a WhatsApp conversation that somebody got, unfortunately from their apartment manager.

32:03 And of course it's addressed to Michael, which is extra funny.

32:06 Hello, Michael.

32:07 Your apartment has received the second complaint.

32:10 noise from the apartment is the problem.

32:12 The dog whines.

32:13 Apparently you leave one home and the dog gets bored.

32:16 Please address this.

32:18 The response from Michael is hello.

32:20 I don't have a dog.

32:21 This is me learning JavaScript.

32:22 Like screaming and yelling and kicking.

32:25 Oh, a dog whines.

32:27 Okay.

32:28 Oh.

32:29 Yeah.

32:31 That's pretty good.

32:33 That is pretty funny.

32:34 It could be like learning all sorts of programs.

32:35 It could be learning Python, but yeah.

32:37 It feels a little extra special.

32:38 A little extra special there.

32:39 Have you got your web pack working?

32:41 Have you got your requires working?

32:43 have you got your transpiler working yet?

32:46 Man, that was me with like trying to relearn CSS.

32:49 so first time I learned CSS, we didn't have all these like pre compilers and stuff.

32:56 so CSS is a completely different ball game now.

32:59 So.

32:59 Yeah.

33:00 Yeah.

33:00 Well, yeah, it's crazy stuff.

33:02 Cool.

33:02 Well, anyway, this is my joke for everyone.

33:04 We've received a noise complaint.

33:06 I'm sorry.

33:06 I don't have a dog.

33:08 Awesome.

33:09 Well, it was a fun episode.

33:10 Thanks again.

33:11 Yeah, sure was.

33:12 See you later.

Back to show page