Learn Python with Talk Python's 270 hours of courses

#426: What's New in PyScript [August 2023] Transcript

Recorded on Thursday, Jun 22, 2023.

00:00 One of the most exciting initiatives in the Python space these days is PyScript, which enables Python running natively in your browser.

00:07 With consistent support from the folks at Anaconda, this project has been making solid strides since its initial release.

00:14 On this episode, we catch up with Fabio Pleiger and Nicholas Tollervé to see where they are with the PyScript project.

00:20 This is Talk Python to Me, episode 426, recorded June 22nd, 2023.

00:25 [Music]

00:37 Welcome to Talk Python To Me, a weekly podcast on Python. This is your host, Michael Kennedy.

00:42 Follow me on Mastodon, where I'm @mkennedy, and follow the podcast using @talkpython, both on fosstodon.org. Be careful with impersonating accounts on other instances, there are many. Keep up with the show and listen to over seven years of past episodes at talkpython.fm.

00:58 We've started streaming most of our episodes live on YouTube. Subscribe to our YouTube channel over at talkpython.fm/youtube to get notified about upcoming shows and be part of that episode.

01:10 This episode is brought to you by JetBrains, who encourage you to get work done with PyCharm.

01:17 Download your free trial of PyCharm Professional at talkpython.fm/done-with-pycharm.

01:24 And it's brought to you by Sentry.

01:27 Don't let those errors go unnoticed.

01:29 Use Sentry.

01:30 Get started at talkpython.fm/sentry.

01:33 Nicolas, Fabio, welcome to Talk Python to Me.

01:36 Hi, how are you, Michael?

01:37 Doing well. I think I should say welcome back.

01:39 You know, I've been on the show a couple of times for various things.

01:43 Most recently, other than this, Also about PyScript and MicroPython, which we'll touch a little bit on as well.

01:52 But yeah, excited to have you both here, excited as always to be talking about PyScript.

01:57 One day I can just feel it, we're going to be living the dream, Python in the browser.

02:02 It's going to be fantastic. Let's do it.

02:04 I'm so, let's hope, yes.

02:05 I mean, is the dream real now?

02:07 That's part of the question.

02:09 We'll see how it's to some degree real, and you all are making great progress on that.

02:13 I'm going to spoiler alert, and that's the thing.

02:15 (laughter)

02:17 Yeah, and Nicholas and I are laughing for a reason, too, which we can't wait to talk about it.

02:24 So that's going to be good.

02:25 We can't wait to hear about it.

02:27 But before we do, like I said, you both have been on the show for a couple of reasons, a couple of episodes previously.

02:33 But quick introductions for folks that don't necessarily know you.

02:36 You want to start, Nicholas?

02:37 Okay, I'll go first.

02:38 I'm Nicholas.

02:39 I'm a principal engineer on the PyScript team at Anaconda.

02:43 And my passion is Python and education, which is one of the other reasons why I was on the show earlier.

02:52 And I've also been involved in all sorts of different aspects of the Python community as well.

02:56 And other interesting things like, Oh, have I got one?

03:00 I think I have BBC micro bits was something that I was involved in and stuff like that.

03:07 So, yep, that's me.

03:08 But right now, I'm doing PyScript.

03:10 And I am joined by my esteemed colleague, Fabio.

03:14 Thank you, Nicholas.

03:15 Well, as you can tell, I work with Nicholas at Anaconda, creator of PyScript, been in the community for a long time as well.

03:23 Probably not— let's not focus on numbers or years.

03:27 But very interested in, just like Niklas, Python for education as well, and the whole community aspect of it, which is mostly why I am here, I would say.

03:38 So I've been involved in a lot of community things, was chairman of EuroPython for, I think, five, six years, then chair of PyCon Italy, co-founder of Python Italia, et cetera.

03:51 Always loved the community aspect of Python.

03:54 And happy to be here. - Yeah, absolutely.

03:55 - Thank you for having us.

03:57 - Yeah, it's great to have you, as always.

03:58 You both mentioned having an interest or background or both in education.

04:03 And Nicholas, I think probably the high watermark is probably the BBC micro bit, which touched, you know, the lives of more students than, you know, almost any other regular school teacher, via massive, massive margin, millions of kids.

04:18 That's amazing.

04:19 But I think another angle here, teaching people to work with Python and getting them started in programming from going from, I have this idea, or I've learned what I got to do in programming until I can make it happen on a machine that is not set up for programming necessarily.

04:33 that gap is pretty far with Python.

04:35 And it's pretty far with most languages, right?

04:37 Like you want to, you do Ruby, probably got to set up some kind of Ruby thing.

04:41 You want to do Java, a bunch of stuff there, right?

04:44 But being able to do it in your browser or something, you just open a page and run it.

04:50 Like there's this educational empowering aspect to it.

04:52 Absolutely.

04:53 And you wouldn't believe the, the interesting situations that teachers have to work in at school and, you know, locked down computers and things like that, where their sysadmins won't install Python or any other kind of programming language.

05:07 Despite here in the UK and all over the U S programming being part of the curriculum, it's mandated in the national curriculum here.

05:14 And I was in a call yesterday with someone who just told me that, the Norwegians have now got programming mandatory in their national curriculum.

05:22 And nobody seems to have told the school admins this.

05:24 So what's the piece of software that was running on everybody's computer in the school?

05:29 It's a, it's a browser.

05:30 So I see where this compensation is going.

05:32 Wouldn't it be great if you had Python that ran in the browser?

05:36 It would solve all your installation problems if you're an educator.

05:40 I mean, how much of JavaScript's rise to fame and continued, not quite dominance, but almost certainly in the front end side dominance has to do just with the fact that it's possible.

05:51 Yes, yes, totally.

05:53 It's not necessarily the best, it's not necessarily what people want, at least not in the early days, but it's possible.

05:58 And that's just a lot of things.

05:59 I think, you know, JavaScript has lots of really wonderful aspects to it.

06:05 I've been using JavaScript for almost 20 years, but it's certainly not a beginner-friendly language.

06:11 I think you can say that with some confidence.

06:13 You could try teaching it to beginners, but with all the coercion rules and gotchas that make sense if you understand JavaScript, but it's quite a journey to get you to that understanding.

06:25 With all of that, it's hard enough just to sort of concentrate on getting Hello World working and things like that. Just a simple proof of concept to show that your development environment is working. But if a language that you're using is the equivalent of trying to teach a five-year-old beginner violinist with a Stradivarius, they're not going to kind of get it, okay? You give them an instrument that helps them take the first steps into programming and Python as a programming language, and this is at the core of Guido's mission At the very beginning, ABC, the language that he based it off, was a teaching language.

07:01 So education and learning and teaching and making sure that Python is teachable is a part of the DNA, which is a wonderful thing.

07:09 It is. It's been around since 1989, I guess, if you put it that way, hasn't it?

07:13 That is the striking difference, honestly, between Python and almost all languages today.

07:18 Like, why BASIC was super popular, why JavaScript is super popular, etc., because it's your only option, right?

07:25 It's the thing, or if not, it's the thing that you have right away there already installed for you.

07:31 And you don't have to go through the pain of trying to download things, install on your system, and whatnot.

07:36 Python, on the contrary, it's very interesting.

07:39 It's the most popular language, but it's because people in specific domain areas chose Python because it was the easiest and the most expressive and, you know, tailored for education.

07:50 And then he started competing with very specific languages that were born to do specific things.

07:57 R is another example.

07:59 R was born with that goal, and that's why it's so good at it.

08:04 Python just happens to be very easy to understand, so data scientists and people adopt it, which is great.

08:11 Python actually, just to close, Python actually is the most popular language, but it has a horrible story for mobile and browser and tablets, the most popular hardware and software on earth.

08:24 And it's still the most popular, which is mind-blowing.

08:27 Yeah, so you would agree if it were good on both, right?

08:30 Yeah, quite. But what you say, Fabio, it reminds me of, was it a keynote?

08:36 Maybe the pre-COVID keynote at PyCon US, where I think one of the keynoters said, "Python is the world's best second-best language." And I think that's kind of the essence of what you've just said.

08:48 R is great for doing stats and maths and things, but so is Python.

08:52 Might not be up there with R for very specialist niche mathematical things, but Python's good enough.

08:59 And because it's easy to learn, folks are going to go fly with that.

09:03 Yeah, I think, building on what you said, Fabio, I think one of the really unique aspects of Python, you know, compare this to like Visual Basic or the super simple programming languages like Scratch, or the super high-end ones like C++ and Rust.

09:19 Python is a full spectrum language.

09:21 Like you can start really easy with a super partial understanding.

09:25 You don't even know what classes are, but you can put six lines together.

09:29 And you can do cool stuff.

09:30 That's like Scratch and Basic and stuff.

09:33 But those languages run out of real programming ideas really soon, where you can just keep growing into Python till you get to the C++ and Rust style.

09:40 Conversely, if you want to start with C++ or Rust, you don't want to teach a beginner what avoid *** is.

09:47 You know, like that's down the road, but you're hit with that kind of stuff soon.

09:51 So I think that's a little bit of its magic as well.

09:54 And what you all are doing to bring that magic to front end of the web world, and kind of through the transitive property a little bit through progressive web apps, to things that run in really good ways on mobile and tablet as well.

10:09 it really unlocks a lot and I'm super excited for it.

10:12 So I know I've had you on before to talk about this, but I'm sure there's some folks out there like, "This sounds amazing. What is this angle bracket Python py-script in my HTML? What is this py-script stuff? Tell us about it." Cool, let me give you a minute, DLDR. So basically py-script is a platform that allows users to create applications or frameworks on top of it and supports Python as a language.

10:43 And it basically uses the browser as technology as its vector, right?

10:49 It treats the browser as almost like a virtual machine.

10:52 It can move around.

10:53 And then because of the current stack around Wasm, WebAssembly on the browser technology, we are now able to run Python inside, you know, either Wazzy or M scripting, which are just implementations of WebAssembly on the browser.

11:09 And PyScript sits on top of interpreters.

11:13 We have the browser, WebAssembly, M script and Wazy, and then a Python implementation, Pyodide or MicroPython or other things like this.

11:22 And PyScript goes on top by providing a friendly interface, higher-level APIs that are Pythonic and friendly, allows extensibility with plugins and things like this to create an ecosystem.

11:34 And basically what we want to do is reuse the ecosystem.

11:38 As much as we can, we don't want to reinvent anything.

11:41 Actually, that's one of the things that I'm most proud of it during this first year, which is I think we made really good progress in helping other projects that are developing and making Python happen on the browser.

11:53 Long story short, PyScript allows you through those tags, PyScript or PyConfig or PyRapple to define what's my environment, what packages I want to install and whatnot.

12:06 And then with the PyScript script, it can define scripts that run your application and then just use it.

12:13 You don't need to install anything, to download anything.

12:16 It just works on the browser.

12:17 Yeah, excellent. I think maybe let me just give one more piece, one more resource for folks out there who might be interested.

12:24 Have you all seen the birth and death of JavaScript by Gary Bernard?

12:27 - Did you see that? - I was there when you gave it.

12:29 Oh my gosh, what was the crowd's reaction like?

12:33 Oh, we were just rolling around, laughing.

12:36 It was great.

12:37 It was great delivery as well.

12:38 So this is a, let's see, 15 minutes, 30 minute presentation he gave at PyCon 2014.

12:45 So quite, quite outdated in like web technology evolution speed.

12:49 But I throw this out there because it's both an amazing comedy skit, but also super nice build up of how you got to places like now with M scritingand WebAssembly and how do you take C code like CPython and run it on top of the browser on the front end.

13:07 So people are interested, they can, you know, they are like, what is all this magic?

13:11 You can have both a really good laugh and watch that, that was good.

13:14 So with PyScript, you can write, just like in JavaScript, You can write JavaScript or in this case, Python in the browser, right?

13:25 Like you could just like, you could say angle bracket JavaScript and just start writing JavaScript code here.

13:30 You can say Py-script, and then you can say print, you know, hello from Python or whatever, and it'll run.

13:36 But you can also have more well-structured applications, right?

13:40 Yes.

13:41 Thinking I might even lean so far saying you should have more well-structured applications.

13:45 Yeah.

13:46 What do you all think?

13:47 One thing about PyScript, and that we are actually trying to work a lot on it, about it, is that it gives a lot of freedom, as you said.

13:55 You can put tags in it, it's just HTML.

13:58 So everything you have access to in an HTML page, you should have access to in PyScript as well.

14:05 So like your tags in the page, your scripts, if you loaded anything in your JavaScript scope, you can import those things in PyScript and say, from JavaScript import this and then just run.

14:17 Actually, one of the things that we're working right now is actually going to explore that even more.

14:23 And we're going to demo that later.

14:25 We have currently a next branch where we are redesigning the core of PyScript and making it smaller, fully web-based, fixing most of the bugs and the very crappy code that I wrote at the beginning.

14:39 And we had an amazing addition to the team from Andrea who's been in tech, in the web for a lifetime.

14:47 And he's amazing.

14:49 And he's bringing that aspect that we lacked and the team, you know, web native point of view.

14:54 Well, Pythonists and Python geeks.

14:57 So we missed that.

14:59 This portion of Talk Python to Me is brought to you by JetBrains and PyCharm.

15:05 Are you a data scientist or a web developer looking to take your projects to the next level?

15:10 Well, I have the perfect tool for you.

15:12 PyCharm is a powerful integrated development environment that empowers developers and data scientists like us to write clean and efficient code with ease.

15:22 Whether you're analyzing complex datasets or building dynamic web applications, PyCharm has got you covered.

15:28 With its intuitive interface and robust features, you can boost your productivity and bring your ideas to life faster than ever before.

15:35 For data scientists, PyCharm offers seamless integration with popular libraries like NumPy, pandas, and matplotlib.

15:42 You can explore, visualize, and manipulate data effortlessly, unlocking valuable insights with just a few lines of code.

15:49 And for us web developers, PyCharm provides a rich set of tools to streamline your workflow.

15:53 From intelligent code completion to advanced debugging capabilities, PyCharm helps you write clean, scalable code that powers stunning web applications.

16:03 Plus, PyCharm's support for popular frameworks like Django, FastAPI, and React make it a breeze to build and deploy your web projects.

16:11 It's time to say goodbye to tedious configuration and hello to rapid development.

16:16 But wait, there's more.

16:17 With PyCharm, you get even more advanced features like remote development, database integration, and version control, ensuring your projects stay organized and secure.

16:26 So whether you're diving into data science or shaping the future of the web, PyCharm is your go-to tool.

16:31 Join me and try PyCharm today.

16:33 Just visit talkpython.fm/done-with-pycharm.

16:38 links in your show notes and experience the power of PyCharm firsthand for three months free.

16:44 PyCharm, it's how I get work done.

16:47 Now we're going to allow also execution in workers or blocking calls, or actually we support other languages as well.

16:56 Like we have demos with Lua or Ruby and things like this.

16:59 And I think that's part of the vision where we want to PyScript to be a tool that allows you to almost do anything with any language and deploy anywhere, right?

17:11 It's beyond Python, even if Python is the primary citizen there.

17:18 We want to make sure that we are unlocking everything for all the users.

17:22 Which is hard.

17:24 Yeah, I'm sure it is.

17:25 Do you see an analogy with Jupyter going from IPython notebooks to Jupyter notebooks and starting to bring on a broader view of the ecosystem, but still kind of being Python at heart.

17:37 Yeah, I think so in a different way than Jupyter.

17:40 Jupyter has always been very self-contained into the notebook itself.

17:45 And the programming paradigm that the notebook brings with it, you know, it's a very, it's an exploration tool rather than editor or authoring tool.

17:55 And then with JupyterLab, it evolved in different things as well.

17:59 I think PyScript has maybe the opposite problem.

18:02 We're too open, which is hard for actually our user base that we want to...

18:08 We said PyScript is for the 99%.

18:11 We need to do a lot of hard work to make it happen.

18:13 -Nicholas. -Well, this is a really great point that Fabio is making.

18:17 And you've got to remember the key word here is that PyScript is a platform.

18:21 Now, it's a platform, you know, the layers of that platform were articulated by Fabio.

18:26 You know, at the bottom is WebAssembly, which runs in your browser, and you can compile, you know, M scripting or other things can sort of work on top of that and blah, blah, blah, blah, blah.

18:35 And then you get PyScript. Okay, so with PyScript, we hope, and we're doing this ourselves to build frameworks on top of that.

18:43 So what's the difference between a framework and a platform? If the platform is like the foundational stuff that gives you the core verbs and nouns and things, okay, the framework is perhaps focused on a particular problem that you're trying to solve, like in the classic Python world, you know, Django and Flask are web frameworks. Okay, you have a matplotlib is a kind of like a framework for creating graphs and things like that. And so we expect people to reuse some of these things, because this is another aspect of having Python in the browser is that you also bring the whole of the Python ecosystem into the browser as well. And then all the modules and the things like that, and that Python brings. So we hope and we're building this sort of stuff.

19:26 And we'll probably come on to that later in this conversation, but we hope the community, because this is an open source project as well, let's not forget.

19:33 The community come along and they start building cool things on top of, of PyScript frameworks and, applications and things.

19:41 So, so that they surprise us and delight us and make us go.

19:44 And this is one of the ways that I would measure our success is that if somebody turns up and goes, I built this thing and I go, Oh man, I never thought anyone And we'll do that with PyScript.

19:56 So when we get to that, then I know we're rocking.

19:59 Yeah.

19:59 You've queued up a nice comment from the audience here.

20:02 Sarah says, I'm exploring Vue.js.

20:05 Shall I wait and use PyScript in my app?

20:08 Great question.

20:10 I think we're coming close to a world where the two play well together, actually very well together.

20:16 So we'll talk about later about PyScript.com, which is an additional thing on top of PyScript.

20:23 And we're using Vue there, too.

20:25 Vue is a great tool for building front-end apps and whatnot.

20:30 But I hope in the future we will have Vue written in Python or something similar, which is more Pythonic.

20:36 So I'd say the thing for Sarah to understand is that because Python's in the browser, it has access to the JavaScript context.

20:44 So you could start to mix and match.

20:47 You've got Vue stuff happening in JavaScript, and you've got Python stuff that could be working in concert with it as well.

20:53 You know, mix it up a bit.

20:55 I don't know, this is an early part of the journey.

20:57 Sarah, you go away and check this out and tell us what you find.

21:00 You know, knock yourself out.

21:02 - Yeah, absolutely. - I'll keep repeating this.

21:05 Anyone that has questions or specific use cases or want to contribute, reach out. We want to hear from you.

21:12 And we are very welcoming, and so come be a contributor.

21:15 Super.

21:16 And just, you know, shout out to Anaconda, Anaconda Inc.

21:19 for making this possible for you all to be working on this in a more dedicated way instead of just, I'm really passionate and I've got an hour a day I can spend on it, but like legitimately, you can be more responsive and put yourself a little more out there 'cause it's not like it, it takes away from that one hour you could add features with.

21:37 - I agree, yeah.

21:38 I will say like we're very lucky and very thankful to Anaconda to support this.

21:42 It's a huge effort, so.

21:44 I would add one more possibility out there for folks in Sarah's situation.

21:49 I would love to see PyVue or something like really ready to work with it.

21:54 And I know the MicroPython work I'm about to ask you all about for a follow-up on makes that really a possible case.

22:03 But if you're really just like, "It's got to be some JavaScript framework," give HTMX a look. It's really, really nice.

22:10 You can just keep writing Python.

22:12 You got to do it on the server and it's kind of a little async type of thing, but that's how all the, a lot of the view stuff happens anyway.

22:18 So if PyScript weren't the answer, maybe consider HTMX before you decide like it's all front end and React and just a bunch of APIs.

22:26 That's really nice stuff.

22:27 All right, back to PyScript.

22:28 What's the story of the MicroPython thing that we spoke about last time?

22:31 Okay, so let's just recap.

22:34 What happened last time was I think I just finished doing the proof of concepts And we had micropython kind of running.

22:42 Okay.

22:42 And that was, that was late last year.

22:45 Wasn't it?

22:46 Yeah.

22:46 It was like six months ago or so.

22:47 Yeah.

22:48 Just about.

22:48 Yeah.

22:49 Yeah.

22:49 Yeah.

22:49 If you can get, yeah.

22:50 Cause we have Brett on the call as far.

22:51 I remember now, if you can get micropython running by the middle of the next year, it's going to be kind of hallelujah moment.

22:59 You know, the crowds will part, the angels will sing and the sun will shine and all of this, yeah.

23:03 Cats and dogs living together.

23:04 All that.

23:05 Yeah, exactly.

23:06 Exactly.

23:06 Sharks with lasers, that sort of thing.

23:08 And who wouldn't want that?

23:09 And so what's happened in the intervening six months?

23:12 So I think two important things have happened.

23:15 The first one is the re-architecting of PyScript.

23:19 And just to reinforce what Fabio said, maybe six months ago, when we said PyScript is Python in the browser, the emphasis was on Python and not so much in the browser.

23:32 Okay.

23:32 Because we've been joined, you know, our colleague, Andrea is very much of the web world. In fact, his nickname inside the team is Web Yoda for a very good reason.

23:41 OK, it's now, you know, Python and we have in the browser has been kind of worked on and we've been looking at how that sort of works and how these two sort of things mesh together. Because Andrea is frankly incredible at this sort of stuff.

23:58 And he's kind of of the web and he knows the idioms and he knows the APIs and he knows how the browsers work and things like that.

24:06 The actual PyScript core that's coming next is very small and very flexible.

24:10 So that's the first sort of pillar of this.

24:12 Second pillar goes by the name of Damian, we all know and love in Melbourne.

24:17 And Damian's a buddy, we worked on the micro bit together.

24:20 That's how we first got to know each other.

24:23 And clearly, I don't think in a million years, Damian imagined that a Python would be running on a browser.

24:29 That's completely the opposite end of the computing spectrum.

24:32 Watch MicroPython become the most popular base to run Python globally.

24:38 It easily could if it goes out on the web.

24:40 Exactly. Now here's the thing.

24:42 Because Pyodide is CPython compiled to WebAssembly.

24:47 And that's we started with Python.

24:49 But depending on how you build it, it's around 11 megabytes if you had the whole, everything but the kitchen sink in there.

24:56 Okay, that's a lot for a web page.

24:58 Okay, I know everybody says the New York Times is however many megabytes it is, but still 11 megs is large.

25:05 And it doesn't play well with these black mirrors that we carry around in our pocket.

25:09 MicroPython, I noticed today, thanks to compression and other things, it's down to 170K to deliver into the browser.

25:17 And with the 50 plus, 50 odd K for the core of PyScripts, the next thing we, we have an incredibly, it's around half a megabyte to get the thing into a browser, which I think it was Simon Willison said that's smaller than some hero images you get on websites.

25:35 Okay, we get a development environment. So we reached out to Damien, and Damien's been working with us. He's been doing an awful lot of work, impeccable work, excellent work to make sure that the story of MicroPython in the browser is that it's kind of like a first class Python. Okay, so he has implemented the FFI, the foreign function interface between Python and the JavaScript context. Okay, it's the same sort of API as you get in Pyodide. Okay, so it's familiar.

26:05 Okay, so you import JS, and then you're away. You're referencing things in the land of JavaScript.

26:10 To be clear for people listening, that means you can hook button click events, you can hook document ready, mouse, like in Python.

26:19 What API functions. Yep.

26:21 I want to play some audio. There's an audio API built into the web, into the browser, I can import JS and then do JS.audio as a class to instantiate something to then play.

26:33 It's just super easy and a real joy to use, but it starts like that.

26:38 And this is, I think, the key aspect of the difference between MicroPython and Pyodide.

26:43 Pyodide gives you all of Python, okay?

26:46 So you want to do some data science or you want to bring in some CPython module to work in the browser, you use Pyodide.

26:52 But if you want something Python-ish, and it's fast, and it goes like the clappers, and it's really quick to load, then MicroPython is the thing for you.

27:00 If you want to start manipulating the DOM and working with what the browser makes available to you.

27:06 And so, to answer Sarah's point, maybe MicroPython is the thing that you should be using to coordinate with that.

27:12 I think it certainly is an alternative to Vue.

27:14 - It would be, yeah. - Yes.

27:16 I really want to chime in on one thing, just because I'm really proud of what we're doing there.

27:22 what Nicholas highlighted, I think it's really great to see projects like MicroPython coming together with Pyodide and PyScript, all talking, "Hey, how can we make things be share the best parts of each project and have a common interface to interface JavaScript?

27:40 How can we make this happen?

27:42 How can we support MicroPython and PyScript?" And so it was, I really need to thank Damian, Hood, Roman from those projects to be so nice and so easy to work with and willing to just, "Yeah, let's talk about it. Let's see what's best for the community." And yeah, great, great work.

28:02 Yeah, it's an absolute joy.

28:03 And I'll tell you a funny story.

28:06 Just after Christmas, we met up, the PyScript team, in real life for the first time.

28:11 And because we were all in the same place, and we had Hood with us, Hood has since joined the team, and because of time zones, we were all able to drop onto a call with Damien.

28:20 and having Hood and Damien talk together for the first time, you'd think, you know, these are exceptionally gifted engineers, okay?

28:29 And after maybe, I don't know, two minutes of small talk, they were talking about, I don't know, the intricacies of garbage collection in the WebAssembly context, and, you know, the whole kind of conversation just went...

28:45 They exploded off into the technical sort of ether, as it were.

28:49 But what I want to highlight is that PyScript has sort of lit a fuse underneath and these projects working together.

28:56 And it's so wonderful to see the open source community working in the way that it should, you know, people bringing the best themselves and being very humble and listening and being compassionate to other people when they, when there are differences of opinion and there are always differences of opinion.

29:11 One of the things that I take away from this project is the amount of fun I have working on this, that people pay me to do this is incredible.

29:18 So that's awesome.

29:22 This portion of Talk Python to Me is brought to you by Sentry.

29:25 You know Sentry for their error tracking service, but did you know you can take that all the way through your multi-tiered and distributed app with their distributed tracing feature?

29:34 Distributed tracing is a debugging technique that involves tracking requests of your system, starting from the very beginning like a user action, all the way to the back end, database, and third-party services.

29:46 This can help you identify if the cause of an error in one project is due to the error in another.

29:51 Every system can benefit from distributed tracing, but they are especially useful for microservices.

29:56 In this architecture, logs won't give you the full picture, so you can't debug every request in full just by reading the logs.

30:03 Distributed tracing with a platform like Sentry gives you a visual overview about which services were called during the execution of certain requests.

30:11 Aside from debugging and visualizing your architecture, distributed tracing also helps you identify performance bottlenecks.

30:18 Through a visual like a Gantt chart, you can see if a particular span in your stack took longer than expected and how it could be causing slowdowns in other parts of your app.

30:27 Learn more and see some examples in the tracing section at docs.sentry.io.

30:32 To take advantage of all the features of the Sentry platform, just create your free account.

30:37 And for all of you, talk Python listeners use the code talkpython, all one word, and you'll activate a free month of their premium paid features. Get started today at talkpython.fm/sentry-trace. That link is in your podcast player show notes in the episode page.

30:53 Thank you to sentry for supporting talk Python to me.

30:57 We kind of introduced the possibility and what we can do with PyScript pretty well, but I can't resist showing this this video here. So Nicholas, you have a one minute video, which I'm going to link to that shows Python running in the browser, which is great.

31:13 And then very nicely, you have it running on a mobile phone, which is really nice.

31:20 Tell people where it runs next.

31:22 In a car.

31:23 So Tesla is basically a computer on wheels, and it has a browser built in.

31:27 This Lucy Goosey app, a colleague of mine, you know, clearly I'm British.

31:32 And she said to me, you've got to be Lucy Goosey about this.

31:34 She's from Boston.

31:35 And I was like, "What on earth is Lucy Goosey?" And she explained.

31:39 And since then, I've been getting Lucy Goosey into all of these kind of places, just to pull her leg a little bit.

31:44 You click on the goose, and it uses the underlying browser's audio API to go honk, right?

31:50 So it's just honking on demand.

31:52 And the fact that you can get a car to honk like a goose kind of seems kind of appropriate in any sort of way.

31:57 - It certainly is for Teslas.

31:59 - Yeah, yeah, exactly, exactly, exactly.

32:02 - They only make weird noises.

32:03 This is MicroPython running on a Tesla, playing Goose.

32:06 I love it.

32:07 And on a mobile.

32:08 Yeah, so maybe the next thing that we could do here is we could talk about one of the bigger announcements that you had recently.

32:15 So there's probably two plus the shift in API and the changes there.

32:20 But one, whoever wants to take this is PyScript.com.

32:23 Yeah, I can talk real quick about it.

32:26 It was the beginning.

32:27 Part of the vision when we started was, okay, cool.

32:30 PyScript needs to be open source and everything always.

32:33 How can we make it it's on the browser, right?

32:36 Like how can we make it even easier for people to just hop in somewhere, start a project and just share it with others.

32:43 And that was, okay, we need a product or something like this.

32:48 So we launched PyScript.com, which is a free service or a free service.

32:53 Right now we actually, the only option for paid features or anything like this is, is really just through being a founder, which is basically in the Kickstarter model, you want to support the project.

33:05 It really is what it is.

33:06 And we're saying a little bit like a GitHub sponsor kind of.

33:09 Yes.

33:09 Yeah.

33:10 And we will always have a free tier with unlimited projects, unlimited ways you can share it, et cetera.

33:17 And we were probably gonna, we were going to have paid features for things that we were probably we're paying or things that are make it worth, you know, But we want to have a place where people can just drop a snippet or a Python application, then share with others.

33:32 One thing that was super clear to me recently was, after also the video of Nicholas, was last keynote I gave in Colombia was, "Hey, how many of you," I asked the question, "How many of you think you can write a Hello World application and then share with 30 people, not technical, like your mom, your family, and others, and share with them within an hour, right?

33:56 Hello World without complexity.

33:58 And then what?

33:59 10 people showed that raised their hands out of 450.

34:02 Yeah, and it'll take a good chunk of that hour to do it, even for the ones who can do it.

34:07 Yes, or even worse, like in a day, not many more raised their hands, right?

34:13 The goal here is really like, you can just hop in, click, you know, start a new project.

34:19 It's already conveniently already a Hello World application by default, right?

34:23 So, and by default, it's shareable anywhere.

34:26 So all of a sudden you come from, Hey, I'm not sure I can deploy the simplest app in the world to my audience.

34:33 And effectively too, it's just a matter of seconds.

34:36 I just need to share the link and then can see, you know, they can see on mobile and things like this.

34:42 Yeah.

34:42 That's the striking thing that messaging that I think to me was clear that we're not doing a good job, right?

34:48 Like we're no, before PyScript, you could still deploy those things on mobile with Pyodide directly and stuff, but it wasn't that easy.

34:57 Right now, like that's the key to Python adoption, Python and education, all of those use cases.

35:03 That's why I really beg everyone talk about PyScript and that's the value sharing and spreading Python all over.

35:11 Yeah.

35:11 Let's look at one of these.

35:12 So if you create an account, you log in, there's a trending in a featured set.

35:17 So one of these is tic-tac-toe and I'll view the site that we can maybe talk about the code real quick.

35:21 So I pulled this up in my browser, it's based on the Pyodide version.

35:25 And down here you can, it does show the terminal just for people who are interested in the print statements, but you can just go play tic-tac-toe on yourself and, you know, end up, you just click crazy, I guess you'll win or something, right?

35:37 The O's win this time.

35:38 But it shows the JavaScript interaction, the click down, the changing the DOM from Python, all those good things, right?

35:44 - Yep. - And so, you can go view the code for it.

35:48 Maybe just we could use this as a chance to just talk through a little bit of like how you're structuring this because you've got a manifest, you've got a main.py, you've got an index.html.

35:59 You come across an app that's written in with PyScript.com.

36:02 You want to know how does it work? You know, the classic, you know, view source, the number of people who said I became a software engineer because in the 90s, when I was a teenager, I could right click view source and figure out what, okay, that's that.

36:14 So I just wanted to highlight that that was there.

36:17 Anypyscript.com app, you'll be able to see the source.

36:20 - And you can copy the project. - Yeah, exactly, we're on the same page.

36:24 There's a copy of the project, which is like a clone to my account, and I'll play with it, right?

36:29 Yeah, exactly.

36:30 That's actually one thing that we've been struggling with, terminology.

36:35 Do we use the usual geek terminology, or are we user-friendly?

36:40 Should we use copy or fork?

36:42 That's a sort of thing. Yeah. Anyway. Yeah. Yes. Nice. Yeah. So tell people quickly about how what you can do with Anypyscript.com kind of how it works. It's a little bit like replete, but really Python focused, right? Yes, it's very similar to replete or, you know, code ban and other services like these that the idea is that you have your space where you host your project. We have an editor right now. We're working also on creating views that are more user friendly. And you don't need to know about HTML or anything like that.

37:12 So just hop in.

37:13 But the nice thing about this is with any project, you can just hop in, see the Python code, how it was done, implemented, and playing around it.

37:21 And we always have the view of the files, then a preview with an iframe that you can see your app, why you develop and whatnot.

37:30 - Yeah. - Mm-hmm.

37:31 - Quickly about the geography of how the project is organized.

37:35 - Mm-hmm, sure.

37:35 - You have your index.html, which is the thing that is first served to the browser.

37:40 And if we go look at that, We'll see that in there, it's just referencing basically all the other things.

37:46 And it's just plain old HTML in there as well.

37:49 So we've got PyScript being loaded as well.

37:51 We've got some CSS.

37:52 They've got the PyScript tag that tells us that main.py is where the application is going to be run from.

37:59 And then we just have the HTML code for displaying the user interface.

38:04 If we hop over to manifest.json, this is an old one.

38:09 The others I have a PyScript.toml, right?

38:12 Yes, I was just going to say, it's usually a PyScript.toml file.

38:16 I can pull that out for us here.

38:18 That's great.

38:19 In the toml file, it's going to be empty because there's nothing there.

38:23 But this is where you start to define characteristics of the environment in which this app is going to run.

38:30 So you might say packages equals and then a list of packages that you want installed as if it were a requirements.txt file.

38:38 Give me a sense of what I can put in that list.

38:41 I know of anything that is pure Python.

38:45 Almost everything.

38:47 There are complicated caveats, which we could go into.

38:52 Overall, the differentiator is really if you're using anything that does multiprocessing or threading or sockets.

39:00 Those on the browser don't really exist.

39:02 Right, so I couldn't use PyMongo or PgMosaico or requests per se, because those are basically violating some...

39:12 - Yes. - ...browser sandboxing rule.

39:14 - Yeah. - Yeah, right.

39:15 A request specifically, there is a package that patches requests.

39:21 So you can actually...

39:22 It's called, for Pyodide, it's Pyodide HTTP, I think.

39:26 And it basically just patches everything.

39:28 After you do that, then you can just import requests and use it normally.

39:32 So it does work right now.

39:33 Yes.

39:34 But so the important thing is, is that you remember that your tab is the conceptually equivalent to your virtualenv.

39:40 Okay.

39:41 And so the PyScript.toml file is just the way PyScript learns about how do you want to configure your environment for this?

39:50 Okay.

39:50 And then if we look in main.py, there we go.

39:53 It's the classic Python.

39:54 This is where you start.

39:56 This is where you just type your Python code.

39:58 just go ahead, import JS and then js.document.whatever to get yourself into the DOM, that sort of stuff.

40:06 - Yep, and from that moment, you have a link that you can share with anyone, right?

40:10 Like it just works.

40:11 Yeah, that's the power of it.

40:13 - Right, excellent.

40:14 So yeah, just got to share or copy it or whatever.

40:17 Okay, so this is a way for people to play with PyScript.

40:21 I saw here in the index that you specifically refer to certain releases of PyScript here.

40:28 So I guess, presumably it's kind of however much you want to stay on the cutting edge of PyScript or kind of just take some version in time and stick with it.

40:37 Yeah.

40:38 Yeah.

40:38 That's actually a great question because we've been discussing that a lot and Hey, just we should actually, should we remove latest and or unstable?

40:47 Those are always linked to the latest stable release and the latest merged commit in the repo.

40:54 And I think ultimately we're leaning towards yes, and always spin the version, mostly because that guarantees that, you know, we're not going to change things under the rug for you and your app.

41:04 It just works.

41:05 It's been courtesy to the user, isn't it?

41:08 I mean, we don't want to do something that breaks their code.

41:11 Okay, so if you pin it to, you know, PyScript version 0.0.1 alpha 1, you know, from way back when dinosaurs ruled the world, but your code still works, it might not be the most up-to-date PyScript, But it's your code, it's your responsibility.

41:25 If you want to update the runtime, you go knock yourself out.

41:28 - Nice. - Or you can use a--

41:29 That's a good idea.

41:31 So that brings up a bit of a comment from ToonArmy out there, who says, "So we're just about out of alpha.

41:37 Do not use in production?" - Yeah, that's a very good question. - What's the status?

41:41 [LAUGHTER]

41:43 YOLO/latest, let's go.

41:45 [LAUGHTER]

41:46 So even with very stable things, I would always recommend pinning all your versions anyway, right?

41:53 I can, and even the secondary versions and whatnot.

41:57 Like when you deploy, pin the thing, pin the thing down.

42:00 And that's what with PyScript.com, we're trying to basically put all those small details baked in so that you don't need to think about those.

42:09 And, you know, just use best practices.

42:12 For instance, we are using config and PyConfig and PyScript with source and not having code in line, right?

42:19 because coding in line is great to get going, but it's really hard to read.

42:24 Editors don't play well with it.

42:26 It's hard to test your code, all of this.

42:29 So we're saying just, let's just use templates that are encouraging best practices and pinning the versions is one of them.

42:35 Could I write unit tests?

42:36 Could I have a page that is like test.html, then import pytest and I do that in the browser.

42:42 Yeah.

42:43 Actually.

42:43 Yeah.

42:43 Yeah.

42:44 So, okay.

42:45 Here's the thing.

42:45 And we've not mentioned Pypercard or Invent that we've renamed it.

42:49 But when I was writing that before, or the kind of proof of concept before PyCon, I had pytest running in the browser.

42:56 I mean, why wouldn't you run it in the browser?

42:59 That's the context literally in which this code is supposed to run.

43:02 So let's run the test suite in the browser.

43:05 And it just works.

43:06 It's lovely.

43:07 Yeah, it'll be 10 minutes to go, hmm, that'd be a good idea to actually seeing the thing.

43:12 A real kind of woohoo, kind of fist pump moment.

43:15 Yeah, that's fantastic. So speaking of...

43:17 Avi, why don't you jump in?

43:18 Yeah, I just want to mention one aspect, which is...

43:21 we don't always think about this.

43:23 Because PyScript runs in your browser, in your client, like, there's no server-side logic or anything like this.

43:30 So scalability comes for free.

43:32 You can scale your Hello World app to a billion users and not notice.

43:38 Because all the computation is going to run on their end, which is another really cool aspect of the whole thing.

43:45 We don't give enough credit to it, but it's important.

43:48 >> Yeah, it absolutely is.

43:50 Unless you have some server sync type of thing, there's no effort other than delivering the WASM bits.

43:57 All right, somewhere buried in here, we have PyperCard. There we go.

44:01 >> Okay.

44:01 >> So you had mentioned that you were working on this.

44:04 Tell us about this, Nick.

44:06 >> Okay. So Peter, when he announced PyScripts the world at PyCon last year, he said, this is going to be for the 99%. And for that, he meant that not developers. Okay. And I'm old enough because I'm dinosaur really in internet time.

44:22 You were on the internet before the web existed.

44:25 I was actually, I was, I remember getting NCSA mosaic onto a 386 machine in my computing lab at university and going, Oh my gosh, this is incredible.

44:38 It was mind blowing.

44:39 That's the first graphical just in two minutes.

44:47 I'll be able to download this picture.

44:48 It'll be so remarkable.

44:49 Yeah.

44:50 There was Archie.

44:50 There was gopher.

44:51 There was telling all before the web.

44:53 Okay.

44:54 That's a whole different podcast for old fellows who were on the web back in the day, we should stop that now we're turning into the internet.

45:02 The internet used to have a sound, Nicholas.

45:05 It had a sound.

45:06 Yes.

45:06 Oh yeah.

45:07 Oh yes.

45:08 Yes.

45:08 Anyway, worry young people, anyone under the age of 40.

45:12 Back then when dinosaurs ruled the world, there was an incredible framework for writing GUI based apps on the early versions of the Mac.

45:24 Okay.

45:24 And it's called HyperCard.

45:26 And, the, the concept is very easy to explain.

45:30 the user interface is just made of a stack of cards.

45:33 Okay.

45:34 And there is always one card being displayed at once and you interact with that card.

45:39 So there might be a button or there might be some text or a link or a picture or a movie, but when you interact with that, it transitions you to another card.

45:47 So it's a little bit like, you know, again, from a similar vintage that those choose your own adventure games where, you know, if you want to kill troll, turn to page 291.

45:55 You want to run away, turn to page 32.

45:57 So you transition to a new state.

45:59 That's a new card or a new piece of text in the adventure game as it were, and so on and so.

46:03 Okay.

46:03 It's really easy to explain that to 11 year olds.

46:06 Okay.

46:07 And so we took that Piper card model and we created something that we demoed at PyCon that allows you to essentially build apps on top of PyScript using these concepts.

46:19 Okay.

46:20 I'm not sure whether these will work still.

46:22 The auto-advance one works.

46:25 You just have to have patience because it takes 10 seconds to auto-advance.

46:28 Yeah.

46:28 Okay.

46:28 So these demos allow me to exercise different aspects of the underlying browser and how that interacts with Python and things.

46:38 But what we've done is we've renamed it from a Pyper card because that has a legacy.

46:44 People think it's going to be HyperCard when in fact it's not HyperCard, it's actually Python in the browser, but we use that card-like metaphor.

46:52 But there are other things that we want to build into that.

46:55 So right now, literally, this is what I do in my day, is I'm thinking very hard and writing first draft of what Invent, this framework, will be so that it makes it easy for people to create user interface led applications using Python and PyScript in the browser, wherever the browser may be, on your Tesla, on your mobile phone, on your tablet, on your desktop, it'll all look the same.

47:21 Now, I've been working at perhaps the Python end of things, but another aspect of this is that we want to make sure that we create a development environment that will probably be end up in PyScript.com that will allow beginner coders in the same way that, you know, my work on Vue tries to give you a code editor that's not as complicated as a Visual Studio code, but it lets you get to the good stuff as quickly as possible.

47:44 So it is a similar sort of philosophy will allow you to draw your user interface, allow you to create the logic that you need to make your app run without actually even realizing that under the hood, you've got Python running as well.

47:57 Very cool. So we should see Pyper card is kind of a proof of concept. And then you're coming out with this, you called it invent, invent. So you literally import, invent, and then import .app or import . whatever. Yeah. Yeah, yeah, yeah. Yeah. Yeah. Yeah.

48:14 I agree in the UK.

48:15 I'll say one thing to you, Nicholas, actually, I'm a little disappointed, to be honest, that I'm the only one that actually is dogfooding Pype Invent and writing my talks with Invent and all of those.

48:28 Yeah.

48:28 You should please.

48:29 For Pype.

48:30 Hey, it's great. I've been using actually Visual PyScript and Invent, etc. for my talk and I was expecting you would say like, yeah, me too.

48:39 You're like, oh, really?

48:41 Really brave of you.

48:43 Just left you hanging dry.

48:46 Yeah, he's got me banged to the right.

48:50 But honestly, one thing that I didn't think before, while in the Uber to the conference, the day before, actually the day of my talk, the ability to actually check my slides and change them on the backseat of a car, on my phone, was mind-blowing and really cool.

49:08 Which helps the power of the framework itself.

49:11 Yeah, kudos.

49:12 So you've told a really good story here because now imagine that you are in a classroom in, I don't know, I'm just picking random country, in Mexico, okay, and you've got a class where there are kids with Chromebooks, okay, getting Python on there, getting any app to be built on those is difficult enough.

49:30 Like with PyScripts, it's going to be so much easier, sort of story to do, that sort of thing.

49:38 So that's, we're working hard on that and it's going to be a long journey, but we're confident that it'll, it'll produce good results.

49:44 Do you have some dreams or have you thought about Git and GitHub integration into pyscript.com?

49:51 Like if I had a pyscript.com thing and a GitHub repo, could I have one mirror the other so that I could do GitHub like things to it?

49:59 Yeah, go ahead, Nicholas.

50:00 I was going to say, I look forward to the feature request on our repository.

50:06 Well, we're listening to the community.

50:09 If that's something that you want, tell us about it.

50:12 Yeah, actually, I would love to hear more about how people would envision it.

50:16 So we already kind of already have it in the sense that people working on both pycript.com, but also the open source project, we have a CLI for both, right?

50:28 The CLI on the open source side allows you to create new projects with a template, to run them locally and those type of things.

50:35 we have a plugin for that CLI that is a PyScript.com plugin that allows you to log in, log out, and then basically have a local copy version of your project that is in .com.

50:47 And one of the first scenarios that we're thinking was, as a developer, probably not as a non-technical user, but as a developer, I want to use GitHub for my version control things, and I want to use PyScript.com to deploy and change things.

51:01 So we do have a minimal integration we're going to be announcing and properly announcing and releasing those things in a month time frame.

51:09 - Nice. - That is one of the most important use cases that we have.

51:14 Yeah.

51:15 Take my thoughts for what they are, is very loosely informed.

51:19 Not a lot of skin in the game, but with my website, my personal website, I use Hugo and then I just push to a branch that triggers a deploy on Netlify.

51:31 you know, there's kind of the Heroku type thing, right?

51:34 It'd be cool if it kind of just like, it goes to this branch, that's what's on PyScript.com.

51:39 That's what I would love if I were doing that integration and using it, but...

51:43 Yeah, that's one use case.

51:46 Interesting that you mentioned, we've been looking at Heroku as well, et cetera.

51:50 The kind of difficulty here is we're often used to a one repo, one app type of separation.

51:58 But you may have like a one repo where let's say you collect all your talks over that you give around conferences.

52:04 You may want to have a folder and each folder is one app on PyScript.com.

52:09 And how do we support those different workflows?

52:12 That's the type of thing I'm thinking right now.

52:14 And that's the thing.

52:16 Sure. Well, people who are using it, reach out to these guys and give me your thoughts here.

52:21 Thank you.

52:22 We're getting, of course, yeah, we're getting short on time.

52:24 So maybe the last thing we should talk about is kind of a PyScript next.

52:28 Where are we going from here folks?

52:30 Yes.

52:31 So let me use this real quick.

52:33 And I think, I think you should have like a link to a bunch of tabs open.

52:37 That one.

52:38 Perfect.

52:38 So what's my script next?

52:40 It's as I said, like we're rewriting py scripts with a smaller core, more flexible, web native, et cetera, to allow different things.

52:47 So this tech preview that we are formally launching next week.

52:52 So, you all listening, it was saw first, and it all happened.

52:57 Awesome. I'm sure the release was amazing, and it went really well.

52:59 So, perfect. Yes, congratulations.

53:02 That's very Doctor Who of you to say that.

53:05 Yeah, it is.

53:06 But the gist of it is that we rethought a lot of the core concepts, and now we're able to allow multiple interpreters.

53:16 We have MicroPython by default, supported by default.

53:20 All of the interpreters support execution on the main thread, just like the previous version of PyScript.

53:26 But now also we support on a worker, a web worker, which means you can run Python while the web is loading or while the page is doing other things.

53:37 It's like there's another process or other processes in your page.

53:41 That's one place to get web workers.

53:43 That's been a big part of WebAssembly for quite a while, but you all haven't leveraged that previously, right?

53:48 Yes. And it was very painful for us because, you know, for instance, panel an internal project of Anaconda, like they have all the examples ported to the web with Pyodide.

53:59 And because we didn't support the workers yet, it was better for them to just use Pyodide directly.

54:05 Now we can allow them to use PyScript and, you know, do all those things.

54:09 We saw actually a type preview of even Django or FastAPI running on PyScript with workers, right? Like, which is extremely cool. And you can think of – That is cool.

54:19 It's hard to actually imagine, but even just the educational purpose of this, you can have live running examples in your docs, and you can just play with it, which is interesting.

54:31 Well, I don't know how well PyScript plugs into this world, but there is an entire ecosystem that I don't operate very much in, but where if you had a, if you have WebAssembly, you can run it kind of like Node can run JavaScript on a server, you can run WebAssembly stuff in the cloud on a server in a container, you can run it directly.

54:51 So in those scenarios, it makes tons of sense to say, we're going to use PyScript to host FastAPI, and it has a meaning, right?

54:58 It's not just browsers all the way down or something, right?

55:01 It has a purpose for being there.

55:03 Yeah, yeah. And well, I wish we had more time.

55:06 There's a lot going on in WebAssembly ecosystem as well to support this as well, which is cool.

55:11 But just in the interest of time, this next branch as well, it also supports communication between workers and the main thread and vice versa.

55:20 So, and we can have multiple interpreters, maybe one is Pyodide, another is Python, another is Lua, and we have examples of those that can communicate between each other.

55:31 If you click on all together, okay, so you've got JavaScript starting MicroPython in a WebWorker, Okay, and then micropython saying hello back to JavaScript.

55:43 But at the same time, micropython on the main thread has actually started in a web worker a Lua interpreter.

55:49 And Lua is saying back to the main thread to micropython, hi micropython.

55:54 And then you've got micropython starting CPython on a web worker.

56:00 And then when CPython has loaded and everything, back to the micropython context, you know, hello micropython.

56:06 This, you know, can you imagine?

56:08 Well, I can actually, because I used to do some work for the UK government, and I was on a data platform, and the civil servants who were doing all the stats work in the Ministry of Justice were using our platform, and they would want data where they wanted to grab data, then run it through some R thing, and then run it through some Python thing, and then stick it on a website somewhere so some minister or a highfalutin civil servant can and go and have a look at the graph of, I don't know, COVID, the spread of COVID through the UK prison system or something like that.

56:41 Well, you can do that all in a single browser.

56:43 The amount of standing on one leg, stick your finger in your ear, and whistle, "God save the king," backwards, you needed to get that to work.

56:50 It took them weeks to just get their development environment set up.

56:54 With WebWorkers and the multiple runtimes, we kind of got that as a solution here now as well.

56:59 Actually, the speed of loading speed, Like you didn't, we didn't have a loading screen.

57:07 We didn't have like, actually, if you check the network.

57:10 Let me try the, the matplotlib.

57:12 Yeah.

57:12 Oh, just try my Python.

57:14 See how fast that brings you up.

57:16 This one.

57:16 Yeah.

57:16 There we go.

57:17 I mean, it's like instant.

57:19 Yeah, it is instant.

57:20 It's amazing.

57:21 Yeah.

57:21 And once it's cached, it's, you know, yeah, it's this kind of stuff that I'm thinking, like, then the front end framework type of story starts to become completely realistic.

57:31 Yeah.

57:31 Yeah.

57:31 Actually, the last one that I wanted to show actually is the next tab that you have, I think, which is--there you go.

57:38 Can you open the console as well?

57:40 Thank you.

57:41 I should use my little hotkey thing here.

57:43 My little--is it like a hotkey you can do to open those?

57:46 Anyway, yeah, okay.

57:47 If you go to console, actually, just to show the results.

57:50 - Yeah. - Perfect.

57:51 So this example is actually having--

57:53 it's a Python input keyword stopping its execution, waiting for an answer.

58:00 - Oh. - I like it.

58:01 So it's actually blocking calls.

58:02 - You're good at it, Matt.

58:03 Seven.

58:03 - Right, and so if you add in...

58:05 - No, no, no, no, no.

58:06 That's the JavaScript console.

58:08 You want to type seven into the input.

58:09 - The input.

58:10 - Ah, okay.

58:12 - So basically what's happening is it's blocking and then waiting for its call while the page is still responsive and everything else.

58:18 And then when you answer, it executes.

58:21 - Mm-hmm.

58:21 - Okay.

58:22 - 'Cause that unlocks a lot of use cases.

58:25 A debugger, for instance, like we can have breakpoints somewhere and you can go and debug your code And a lot of scenarios that were not working before can work now.

58:35 So this is very exciting.

58:37 Yeah, there's a lot of under the hood stuff that has changed that enables us to do some really cool things now.

58:43 Yeah, excellent. So with the web workers, do I get async and await?

58:47 Yes, and proper async and await. Yes.

58:50 - Yes. - That's fantastic.

58:51 Okay, I love it.

58:53 All right, guys, what else?

58:55 What final things do you want to tell people before we wrap up this PyScript update episode.

59:01 I've got two things.

59:02 First one is, if you want to play, if you want to have a look around, PyScript.com is the place to just get your hands dirty.

59:09 And our colleagues who work on that have done an amazing job.

59:13 And the feedback that you can give them through the form that you'll find on the website is read.

59:17 And we care very deeply about, you know, the experience that users have and suggestions and things.

59:23 So knock yourself out, go and do that.

59:25 And the second thing I want to say is that PyScript is open source software.

59:29 So I know Fabio and myself are employed by Anaconda, but we have contributors who are not Anaconda employees.

59:35 And, you know, we would love the community to come with us on this journey.

59:39 Tell us what you want.

59:41 Build a framework on top of PyScript.

59:43 Build plugins on top of PyScript.

59:44 Create a goofy app on top of PyScript.

59:46 You know, put it on your Tesla or whatever.

59:48 You know, I don't know.

59:49 I would love, it would make my day if before the end of the year, somebody's gone, "Hey, I've built a Death Star using PyScript or some ridiculous project or whatever." And I go, "Wow." Like I said, I never thought someone would do that.

01:00:03 Be playful, explore, be creative, have fun.

01:00:06 That's what I want to see.

01:00:08 Fabio, how about you?

01:00:10 Yeah, I would actually just double down what you said and actually encourage everyone to reach out.

01:00:17 We're trying to make it a good tool for anyone to learn programming or to share your things, et cetera.

01:00:24 And a lot of the difficulties we have all the time is trying to think with new users' brain or students' brain and people with different backgrounds, because unfortunately or fortunately, we've been in this game for 20 years, right?

01:00:41 So it's really hard.

01:00:42 So when we say, "Reach out, we need you," we really mean it.

01:00:47 Like, I think I strongly believe that all open source projects are about people and benefit from diversity, right?

01:00:56 Like good docs are made by non-developers.

01:00:59 Good content is made by people that have passion for hopping on a video and talking about stuff.

01:01:08 Like I'm trying to convince my daughter to have like a PyScript channel on TikTok.

01:01:13 Just to talk--

01:01:14 - Oh, that'd be cool, yeah.

01:01:15 - Right, to talk the lingo.

01:01:17 So we really value you reaching out and coming and helping us be more, you know, human as a project.

01:01:24 And the second thing is really help us spread the word and make it popular so that we can make Python even more popular and help people.

01:01:33 Which I think in this age where we have AI and big tech companies and algorithms and all of that, giving power to people to just run programming language on their machines and the distributed nature of PyScript, I think it's important today.

01:01:49 So, yeah, that's all I wanted to say.

01:01:51 Yeah, excellent. Maybe a quick final question.

01:01:54 Marwan says, "Any work on the HTML canvas for your PyScript?" Thinking of simple stuff like creating a snake game.

01:02:00 Okay, Marwan, import JS.

01:02:02 Now you have global this, okay?

01:02:04 Now you have access to your canvas.

01:02:07 And it's the same API because we're proxying the JavaScript objects as you'll find on the Mozilla developer docs.

01:02:14 - So go knock yourself out. - Awesome.

01:02:16 Yeah, that's what I imagine.

01:02:18 MDN network, W3Schools, if you can choose.

01:02:22 Yes, MDN.

01:02:24 I'm also working on a higher level web API for PyScript, which will help with that as well, make the API more Pythonic.

01:02:33 But what they've got is available today, and you can just...

01:02:36 Yeah, and you get to reuse your JavaScript skills if you have them. Yeah, it's the same API. It's the same API Yeah. All right guys. Thank you for being here. Thank you for this project It's really really exciting and I look forward to catching up again and seeing what else built in six months or a year whenever it turns out to be. Yes, and This and running the show this is this is always a great fun. Thank you. Yes. Thank you. Yeah, you bet. Bye. Bye This has been another episode of Talk Python to Me.

01:03:06 Thank you to our sponsors.

01:03:08 Be sure to check out what they're offering.

01:03:09 It really helps support the show.

01:03:11 The folks over at JetBrains encourage you to get work done with PyCharm.

01:03:16 PyCharm professional understands complex projects across multiple languages and technologies, so you can stay productive while you're writing Python code and other code like HTML or SQL.

01:03:27 Download your free trial at talkpython.fm/done-with-pycharm.

01:03:32 Take some stress out of your life.

01:03:34 Get notified immediately about errors and performance issues in your web or mobile applications with Sentry.

01:03:41 Just visit talkpython.fm/sentry and get started for free.

01:03:45 And be sure to use the promo code talkpython, all one word.

01:03:49 Want to level up your Python?

01:03:51 We have one of the largest catalogs of Python video courses over at Talk Python.

01:03:55 Our content ranges from true beginners to deeply advanced topics like memory and async.

01:04:00 And best of all, there's not a subscription in sight.

01:04:03 Check it out for yourself at training.talkpython.fm.

01:04:06 Be sure to subscribe to the show, open your favorite podcast app, and search for Python.

01:04:10 We should be right at the top.

01:04:12 You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the Direct RSS feed at /rss on talkpython.fm.

01:04:21 We're live streaming most of our recordings these days.

01:04:24 If you want to be part of the show and have your comments featured on the air, be sure to subscribe to our YouTube channel at talkpython.fm/youtube.

01:04:33 This is your host, Michael Kennedy.

01:04:34 Thanks so much for listening.

01:04:35 I really appreciate it.

01:04:36 Now get out there and write some Python code.

01:04:39 (upbeat music)

01:04:41 (upbeat music)

01:04:44 (upbeat music)

01:04:46 [Music]

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon