#426: What's New in PyScript [August 2023] Transcript
00:00 One of the most exciting initiatives in the Python space these days is PyScript,
00:03 which enables Python running natively in your browser.
00:06 With consistent support from the folks at Anaconda, this project has been making solid strides since its initial release.
00:13 On this episode, we catch up with Fabio Pliger and Nicolas Tolervé to see where they are with the PyScript project.
00:19 This is Talk Python to Me, episode 426, recorded June 22, 2023.
00:24 Welcome to Talk Python to Me, a weekly podcast on Python.
00:40 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.
00:50 Be careful with impersonating accounts on other instances.
00:52 There are many.
00:54 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.
01:02 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 dash with dash 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 Nicholas, Fabio, welcome to Talk Python to Me.
01:36 Hi.
01:36 How are you, Michael?
01:37 Doing well.
01:37 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.
01:54 Excited, as always, to be talking about PyScript.
01:56 One day I can just, I feel it.
01:58 We're going to be living the dream.
01:59 Python in the browser.
02:02 It's going to be fantastic.
02:03 Let's do it.
02:04 I hope so.
02:04 Let's hope.
02:05 Yes.
02:05 I mean, is the dream real now?
02:07 That's kind of part of the question.
02:09 And we'll see how it's to some degree real.
02:11 And you all are making great progress on that.
02:13 I'm going to spoil it.
02:14 That's the thing.
02:17 Yeah.
02:17 And like, Nicholas and I are laughing for a reason too, which we can't wait to, you know, talk about it.
02:24 So that's going to be good.
02:25 We can't wait to hear about it.
02:26 But before we do, you know, like I said, you both have been on the show for a couple of reasons,
02:31 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 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.
03:01 BBC Micro:bit 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:13 Thank you, Nicholas.
03:14 Well, as you can tell, I work with Nicholas at Anaconda, creator of PyScript.
03:19 Been in the community for a long time as well.
03:23 Probably not.
03:24 Let's not focus on numbers or years.
03:26 So I'm very interested in, just like Nicholas, Python for education as well.
03:32 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.
03:41 I was chairman of EuroPython for, I think, five, six years.
03:45 Then chair of Python Italy, co-founder of Python Italia, et cetera.
03:51 Always loved the community aspect of Python.
03:54 And happy to be here.
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,
04:09 you know, the lives of more students than, you know, almost any other regular school teacher
04:16 by a 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
04:23 programming from going from I have this idea or I've learned what I got to do in programming
04:28 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 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 interesting situations that teachers have to work in at school and,
05:01 you know, locked down computers and things like that where their sys admins won't install
05:05 Python or any other kind of programming language, despite here in the UK and all over the US programming
05:11 being part of the curriculum and 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
05:20 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 browser.
05:30 So I see where this conversation 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:39 Yeah.
05:40 I mean, how much of JavaScript's rise to fame and continued, not quite dominance, but almost certainly
05:46 in the front inside dominance has to do just with the fact that it's possible.
05:50 Yes.
05:51 Yes.
05:52 Totally.
05:53 It's not necessarily the best.
05:54 It's not necessarily what people want, at least not in the early days, but it's possible.
05:58 And, and that's, it's a lot of things.
05:59 I think, you know, JavaScript has lots of really wonderful aspects to it.
06:04 I've been using JavaScript for almost 20 years, but it's certainly not a beginner friendly
06:10 language.
06:10 I think you could say that with some confidence.
06:13 You could try teaching it to beginners, but with all the coercion rules and gotchas that
06:19 make sense if you understand JavaScript, but it's quite a journey to get you to that understanding.
06:24 With all of that, it's hard enough just to sort of concentrate on getting Hello World working
06:29 and things like that.
06:30 Just a simple proof of concept to show that your development environment is working.
06:36 But if a language that you're using is the equivalent of trying to teach a five year old
06:41 beginner violinist with a Stradivarius, they're not going to kind of get it.
06:45 Okay.
06:46 Yeah.
06:47 You give them an instrument that helps them take the first steps into programming and Python
06:52 as a programming language.
06:54 And this is at the core of Yido's mission at the very beginning.
06:58 A, B, C, 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,
07:08 which is a one.
07:09 It is.
07:09 It's been around since 1989, I guess.
07:11 Yeah.
07:11 You put it that way, hasn't it?
07:12 Yeah.
07:12 That is the striking difference, honestly, between Python and almost all languages today.
07:18 Right?
07:18 Like why basic was super popular, why JavaScript is super popular, etc.
07:23 Because it's your only option.
07:25 Right?
07:25 And it's the thing.
07:26 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,
07:35 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
07:45 because it was the easiest and the most expressive and tailored for education.
07:50 And then it started competing with very specific languages that were born to do specific things.
07:56 Like, you know, R is another example.
07:59 Like, R was born with that goal.
08:02 And that's why it's so good at it.
08:04 Python just happens to be very easy to understand.
08:07 So data scientists and people adopt it, which is great.
08:11 Python actually, just to close, Python actually is the most popular language,
08:15 but it has a horrible story for mobile and browser and tablets.
08:20 The most popular hardware and software on earth.
08:24 Right?
08:24 And it's still the most popular, which is mind blowing.
08:27 Yeah.
08:28 Yeah.
08:28 So what it would be if it were good on both, right?
08:30 Yeah, quite.
08:31 But what you say, Fabio, it reminds me of a keynote, maybe the pre-COVID keynote at PyCon US,
08:40 where I think one of the keynotes said, Python is the world's best second best language.
08:45 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:53 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.
09:03 I think building on what you said, Fabio, I think one of the really unique aspects of Python,
09:09 Python, you know, compare this to like visual basic or the super simple programming languages
09:14 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 and you can do cool stuff.
09:30 That's like scratch and basic and stuff.
09:32 But those languages run out of real programming ideas really soon where you just keep growing into Python
09:38 until you get to the C++ and Rust style.
09:40 Conversely, if you want to start with C++ or Rust, like you don't want to teach a beginning what avoid star star is.
09:46 You know, like that's down the road, but like you're hit with that kind of stuff soon.
09:51 So I think that 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 There's 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.
10:19 What is this angle bracket Python, Python, Python script in my HTML?
10:27 What is this PyScript stuff?
10:28 Tell us about it.
10:29 Cool.
10:29 Let me give you one minute.
10:32 So basically PyScript is a platform that allows users to create applications or forms.
10:39 frameworks on top of it and supports Python as a language.
10:43 And it basically uses the browser as technology as its vector.
10:49 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 pipeline inside, you know, either WASI or MScripten, 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 and then a Python implementation, Pyodide or MicroPython or other things like this.
11:21 And PyScript goes on top by providing a friendly interface, higher level APIs that are, you know, Pythonic and friendly, allows extensibility with plugins and things like this to create an ecosystem.
11:33 And basically what we want to do is reuse the ecosystem.
11:37 As much as we can, we don't want to reinvent anything.
11:41 So actually, that's one of the things that I'm most proud of it during this first year, which is I think we've made really good progress in helping other projects that are, you know, developing and making Python happen on the browser.
11:53 Wrong story short, PyScript allows you through those tags, PyScript or PyConfig or PyRaple to define, you know, what's my environment, what packages I want to install and whatnot.
12:05 And then with the PyScript script, you can define scripts that run your application and then just use it.
12:12 You don't need to install anything to download anything.
12:15 It just works on the browser.
12:16 Yeah, excellent.
12:17 I think maybe let me just give one more piece, one more resource for folks out there who might be interested.
12:23 Have you all seen the birth and death of the office script by Gabriel?
12:26 Yeah.
12:27 Do you see that?
12:28 I was there when you gave it.
12:29 Oh, my gosh.
12:30 Amazing.
12:31 What was the crowd's reaction like?
12:32 Oh, we were just rolling around.
12:34 It laughed.
12:35 Yeah, it was great.
12:36 It's great delivery.
12:37 Yeah.
12:38 So this is a, let's see, 15 minutes, you know, 30 minute presentation he gave at PyCon 2014.
12:44 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 buildup of how you got to places like now within script in and WebAssembly.
13:01 And how do you take C code like CPython and run it on top of the browser on the front end?
13:06 So people are interested.
13:07 They can, you know, they are like, what is all this magic?
13:10 You can have both a really good laugh and watch that.
13:13 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:24 Like you could just like you could say angle bracket JavaScript and just start writing JavaScript code.
13:29 Here you can say py dash script.
13:31 You can say print, you know, hello from Python or whatever.
13:35 And it'll run.
13:36 But you can also have more well structured applications, right?
13:39 Yes.
13:40 I think I might even lean so far saying you should have more well structured applications.
13:44 Yeah.
13:45 What do you all think?
13:45 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, right?
13:54 You can put tags in there.
13:55 It's just HTML.
13:57 So everything you have access to in an HTML page, you should have access to with PyScript as well.
14:04 So like your tags in the page, your scripts, if you loaded anything in your JavaScript, you know, scope, you can import those things in PyScript and say from JavaScript import this and then just run.
14:16 Actually, one of the things that we're working right now is actually going to explode that even more.
14:22 And we're going to demo later.
14:24 We have currently a next branch where we are redesigning the core of PyScript and making it smaller, fully web based, you know, fixing most of the bugs and the very crappy code that I wrote at the beginning.
14:38 Right.
14:39 And we had an amazing addition to the team from Andrea, who's been in tech tech and on the web for a lifetime.
14:47 And he he's amazing.
14:48 And he's bringing that aspect that we lacked and the team.
14:51 Well, you know, we have native point of view.
14:53 We will.
14:54 Well, Python is and Python geeks.
14:56 So we missed that.
14:57 This portion of talk Python to me is brought to you by JetBrains and PyCharm.
15:04 Are you a data scientist or a web developer looking to take your projects to the next level?
15:09 Well, I have the perfect tool for you.
15:11 PyCharm.
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:20 Whether you're analyzing complex data sets or building dynamic web applications.
15:25 PyCharm has got you covered with its intuitive interface and robust features.
15:30 You can boost your productivity and bring your ideas to life faster than ever before.
15:34 For data scientists, PyCharm offers seamless integration with popular libraries like NumPy, Pandas and Matplotlib.
15:40 You can explore, visualize and manipulate data effortlessly, unlocking valuable insights with just a few lines of code.
15:47 And for us web developers, PyCharm provides a rich set of tools to streamline your workflow.
15:52 From intelligent code completion to advanced debugging capabilities, PyCharm helps you write clean, scalable code that powers stunning web applications.
16:01 Plus, PyCharm's support for popular frameworks like Django, FastAPI and React make it a breeze to build and deploy your web projects.
16:09 It's time to say goodbye to tedious configuration and hello to rapid development.
16:14 But wait, there's more!
16:16 With PyCharm, you get even more advanced features like remote development, database integration, and version control, ensuring your projects stay organized and secure.
16:24 So whether you're diving into data science or shaping the future of the web, PyCharm is your go-to tool.
16:30 Join me and try PyCharm today.
16:32 Just visit talkpython.fm/done-with-pycharm, links in your show notes, and experience the power of PyCharm firsthand for three months free.
16:43 PyCharm, it's how I get work done.
16:46 I think it's a really good idea.
16:47 I think it's a really good idea.
16:48 I think it's a really good idea.
16:49 I think it's a really good idea.
16:50 I think it's a really good idea.
16:51 I think it's a really good idea.
16:52 I think it's a really good idea.
16:53 I think it's a really good idea.
16:54 I think it's a really good idea.
16:55 I think it's a really good idea.
16:56 I think it's a really good idea.
16:57 I think it's a really good idea.
16:58 I think it's a really good idea.
16:59 I think it's a really good idea.
17:00 I think it's a really good idea.
17:01 I think it's a really good idea.
17:02 I think it's a really good idea.
17:03 I think it's a really good idea.
17:04 I think it's a really good idea.
17:05 I think it's a really good idea.
17:06 to almost do anything with any language and deploy anywhere.
17:10 Right?
17:11 It's beyond Python.
17:13 Even if Python is the primary citizen there, we want to make sure that we are locking everything
17:20 for all the users.
17:22 Which is hard.
17:23 Yeah, I'm sure it is.
17:24 Do you see an analogy with Jupyter going from IPython notebooks to Jupyter notebooks and starting to bring on a broader view
17:33 of the ecosystem, but still kind of being Python at heart?
17:36 Yeah, I think so in a different way than Jupyter.
17:39 Jupyter has always been very self-contained into the notebook itself and the programming paradigm that the notebook brings with it.
17:49 You know, it's very, it's an exploration tool rather than editor authoring
17:54 to it.
17:55 And then with JupyterLab, it evolved in different things as well.
17:58 I think PyScript has maybe the opposite problem.
18:01 We're too open, which is hard for actually our, user base that we want to, we set PyScript as for the 99%.
18:10 We need to do a lot of hard work to make it happen.
18:12 Nicholas.
18:13 Well, this is a really great point that Fabio is making.
18:16 And you've got to remember the keyword here is that PyScript is a platform.
18:20 Now it's a platform.
18:21 You know, the layers of that platform were articulated by Fabio.
18:25 You know, at the bottom is WebAssembly, which runs in your browser and you can compile,
18:29 you know, mscripten or other things can sort of work on top of that and blah, blah, blah, blah, blah.
18:35 And then you get PyScript.
18:36 Okay.
18:37 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?
18:45 If the platform is like the foundational stuff that gives you the core verbs and nouns and things.
18:50 Okay.
18:51 The framework is perhaps focused on a particular problem that you're trying to solve.
18:55 Like in the classic Python world, you know, Django and Flask are web frameworks.
19:00 Okay.
19:01 You have a, you know, matplotlib is a kind of like a framework for creating graphs and things like that.
19:06 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.
19:17 And then all the modules and the things like that, that Python brings.
19:22 So we hope, and we're, we're building this sort of stuff and we'll probably come onto that later in this conversation, but we hope the community, because this is an open source project as well.
19:32 Let's not forget the community come along and they start building cool things on top of, of PyScript frameworks and applications and things.
19:40 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.
19:50 And I go, oh man, I never thought anyone would do that with PyScript.
19:54 Yeah.
19:55 When we get to that, then I know we're rocking.
19:58 Yeah.
19:59 You've queued up a nice comment from the audience here.
20:01 Sarah says I'm exploring Vue JS.
20:04 Shall I wait and use PyScript in my app?
20:06 Great question.
20:07 I think we're coming close to a world where the two play well together, actually very well together.
20:15 So like we'll talk about later, later about PyScript.com, which is an additional thing on top of PyScript.
20:22 And we're using Vue there too, right?
20:24 Like Vue is a great tool for building, you know, front end apps and whatnot.
20:29 But I hope, yeah, I hope in the future we will have Vue written in Python or something similar, which is more Pythonic.
20:35 So I say here's the thing for Sarah to understand is that because Python's in the browser, it has access to the JavaScript context.
20:43 So you could start to mix and match.
20:46 You know, 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:52 You know, mix it up a bit.
20:54 I don't know.
20:55 This is an early part of the journey.
20:56 Sarah, you go away and check this out and tell us what you find, you know, knock yourself out.
21:01 Yeah.
21:02 Yeah, absolutely.
21:03 I'll keep repeating this.
21:04 Anyone that has questions or specific use cases or want to contribute, reach out.
21:09 We want to hear from you and we are very welcoming.
21:13 And so come be a contributor.
21:14 Super.
21:15 Yeah.
21:16 And just, you know, shout out to Anaconda, Anaconda Inc.
21:18 for making this possible for you all to be working on this in a more dedicated way instead of just really passionate.
21:25 I've got an hour a day I can spend on it.
21:26 But like legitimately, you can be more responsive and put yourself a little more out there because it's not like it.
21:33 It takes away from that one hour you could add features with.
21:36 I agree.
21:37 Yeah.
21:38 I would say like we're very lucky and very thankful to Anaconda to support this.
21:42 It's a huge effort.
21:43 So, yeah.
21:44 I would add one more possibility out there for folks in Sarah's situation.
21:49 I would love to see PyView or something like really ready to work with it.
21:54 I know the MicroPython work I'm about to ask you, just about to ask you all about for a follow up on, makes that really a possible case.
22:02 But if you're really just like, it's got to be some JavaScript framework, give HTMLX a look.
22:07 It's really, really nice that you can just keep writing Python.
22:12 You got to do on the server and it's kind of a little async type of thing.
22:14 But that's how a lot of the view stuff happens anyway.
22:17 So if PyScript weren't the answer, maybe consider HTMLX before you decide like it's all front end and React and just a bunch of APIs.
22:25 That's really nice stuff.
22:26 All right.
22:26 Back to PyScript.
22:27 What's the story of the MicroPython thing that we spoke about last time?
22:30 Okay.
22:31 So let's just recap.
22:33 What happened last time was I think I just finished doing the proof of concepts and we had MicroPython kind of running.
22:41 Okay.
22:42 And that was, that was late last year, wasn't it?
22:45 Yeah, it was like six months ago or so.
22:46 Yeah.
22:47 Just about.
22:48 Yeah.
22:49 Yeah.
22:50 Yeah.
22:51 If you can get, yeah.
22:52 Cause we had Brett on the call as well.
22:53 I remember now.
22:54 If you can get MicroPython running by the middle of next year, it's going to be a kind of hallelujah moment.
22:58 You know, the crowds will part, the angels will sing and the sun will shine and all of this sort of stuff.
23:02 Yeah.
23:03 Cats and dogs living together, all that.
23:04 Yeah, exactly.
23:05 Exactly.
23:06 Sharks with lasers, that sort of thing.
23:07 And who wouldn't want that?
23:09 And so what's happened in the intervening six months?
23:11 So I think two important things have happened.
23:14 The first one is the re-architecting of PyScript.
23:18 And just to reinforce what Fabio said.
23:23 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:31 Okay.
23:32 Because we've been joined, you know, our colleague Andrea is very much of the web world.
23:36 In fact, his nickname inside the team is Web Yoda for a very good reason.
23:41 Okay.
23:42 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.
23:53 Because Andrea is frankly incredible at this sort of stuff and he's kind of off the web and he knows the idioms and he knows the APIs and he knows how the browsers work and things like that.
24:05 The actual PyScript core that's coming next is very small and very flexible.
24:09 So that's the first sort of pillar of this.
24:11 Second pillar goes by the name of Damien.
24:14 We all know and love in Melbourne.
24:16 And, you know, Damien's a buddy.
24:18 We worked on the micro bit together.
24:19 That's how we first got to know each other.
24:22 And clearly, I don't think in a million years, Damien imagined that micro Python would be running on a browser.
24:29 That's completely the opposite end of the computing spectrum.
24:32 Watch, watch micro Python become the most popular base to run Python globally.
24:37 It easily could if it goes out on the web.
24:39 Exactly.
24:40 Now, here's the thing.
24:41 Because Pyodide is CPython compiled to WebAssembly and that's, we started with PySquid.
24:48 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:55 Okay.
24:55 And that's a lot for a web page.
24:57 Okay.
24:58 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:08 Micro Python, I noticed today, thanks to compression and other things, it's down to 170k.
25:15 Let's deliver into the browser.
25:17 And with the 50, 50 plus 50 odd K for the core of PyScript.
25:23 And then we're going to do the next thing.
25:24 We have an incredible, it's around half a megabyte to get the thing into your browser, which I think it was Simon Willis and said that's smaller than some hero images you get on websites.
25:34 Okay.
25:35 So you get a development environment.
25:37 So we reached out to Damien and Damien's been working with us.
25:40 He'd be 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.
25:50 Okay.
25:51 So he has implemented the, the FFI, the foreign function interface between Python and the JavaScript context.
25:58 Okay.
25:59 It's the same sort of API as you get in Pyodide.
26:02 Okay.
26:03 So it's familiar.
26:04 Okay.
26:05 So you import JS and then you're away.
26:07 You're referencing things in the land of JavaScript.
26:09 To be clear for people listening, that means you can hook button click events.
26:14 You can hook document ready mouse, like in Python.
26:18 What APIs?
26:19 Functions.
26:19 Functions.
26:20 Yep.
26:21 I want to play some audio.
26:22 There's an audio API built into the web, into the browser.
26:25 I can import from import JS and then do JS.audio as a class to instantiate something to then play.
26:32 It's just super easy and a real joy to use, but it starts like that.
26:37 And this is, I think the key aspects of the difference between MicroPython and Pyodide.
26:43 Pyodide gives you all of Python.
26:45 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.
26:50 You use Pyodide.
26:51 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.
26:59 If you want to start manipulating the DOM and working with what the browser makes available to you.
27:05 And so to answer Sarah's point, maybe MicroPython is the thing that you should be using to coordinate with that.
27:11 I think it certainly is an alternative to Vue.
27:13 It would be.
27:14 Yeah.
27:15 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:39 How can we make this happen?
27:41 How can we support MicroPython in PyScript?
27:44 And so it was, I really need to thank Damien, 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.
27:57 Let's see what's best for the community.
27:59 And yeah, great, great work.
28:01 Yeah, it's an absolute joy.
28:03 And I'll tell you a funny story.
28:05 Just after Christmas, we met up the PyScript team in real life for the first time.
28:10 And because we were all in the same place and we had Hood with us, Hood has since joined the team.
28:14 And because of time zones, we were all able to drop onto a call with Damien and having Hood and Damien talk together for the first time.
28:23 You'd think, you know, these are exceptionally gifted engineers.
28:28 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.
28:40 And, you know, the whole kind of conversation just went, they exploded off into the technical sort of ether as it were.
28:47 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.
28:59 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:10 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:17 So.
29:18 That's awesome.
29:19 This portion of Talk Python to Me is brought to you by Sentry.
29:24 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:33 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 backend, database and third party services.
29:44 This can help you identify if the cause of an error in one project is due to the error in another.
29:50 Every system can benefit from distributed tracing, but they're especially useful for microservices.
29:55 In this architecture, logs won't give you the full picture.
29:58 So you can't debug every request in full just by reading the logs.
30:01 Distributed tracing with a platform like Sentry gives you a visual overview about which services were called during the execution of certain requests.
30:10 Aside from debugging and visualizing your architecture, distributed tracing also helps you identify performance bottlenecks.
30:17 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:26 Learn more and see some examples in the tracing section at docs.Sentry.io.
30:31 To take advantage of all the features of the Sentry platform, just create your free account.
30:35 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.
30:44 Get started today at talkpython.fm/sentry-trace.
30:48 That link is in your podcast player show notes and the episode page.
30:52 Thank you to Sentry for supporting Talk Python to me.
30:55 We kind of introduced the possibility and what we can do with PyScript pretty well, but I can't resist showing this video here.
31:03 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:11 And then very nicely, you have it running on a mobile phone, which is really nice.
31:18 Yeah.
31:19 Tell people where it runs next.
31:20 In a car.
31:21 So, Tesla is basically a computer on wheels and it has a browser built in.
31:26 This loosey-goosey app.
31:28 A colleague of mine, you know, clearly I'm British.
31:30 And she said to me, you've got to be loosey-goosey about this.
31:33 She's from Boston.
31:34 And I was like, what on earth is loosey-goosey?
31:37 And she explained.
31:38 And since then I've been getting loosey-goosey into all of these kind of places, just to pull her leg a little bit.
31:42 You click on the goose and it uses the underlying browser's audio API to go honk, right?
31:49 So, it's just honking on demand.
31:51 And the fact that you can get a car to honk like a goose kind of seems kind of appropriate in a funny sort of way.
31:57 It certainly is for Teslas.
31:58 Yeah, yeah.
31:59 Exactly.
32:00 Exactly.
32:01 They already make weird noises.
32:02 This is MicroPython running on the Tesla, playing goosey.
32:06 I love it.
32:07 Hang on a mobile.
32:08 Yeah.
32:09 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:14 So, there's probably two plus the shift in API and the changes there.
32:19 But one, whoever wants to take this is PyScript.com.
32:23 Yeah, I can talk real quick about it.
32:25 Here's the beginning.
32:26 Part of the vision when we started was, okay, cool.
32:29 PyScript needs to be open source and everything always.
32:32 How can we make it?
32:33 It's on the browser, right?
32:35 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:47 So, we launched PyScript.com, which is a free service or a freemium service.
32:52 Right now, we actually, the only option for paid features or anything like this is really just through being a founder, which is basically in the Kickstarter model, you want to support the project.
33:04 It really is what it is.
33:05 A little bit like a GitHub sponsor, kind of.
33:08 Yes.
33:09 Yeah.
33:10 And we will always have a free tier with unlimited projects, unlimited ways you can share it, etc.
33:17 And we're probably going to, we're going to have paid features for things that we're paying or things that make it worth, you know.
33:24 But we want to have a place where people can just drop a snippet or a Python application, then share with others.
33:31 Like, one thing that was super clear to me recently was after also the video of Nicolas was last keynote I gave in Columbia 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.
33:55 Right.
33:56 Hello World without complexity.
33:57 Exactly.
33:58 And then what?
33:59 And people showed that raise their hands out of 450.
34:01 Yeah.
34:02 And it'll take a good chunk of that hour to do it, even for the ones who can do it.
34:06 Yeah.
34:07 Yes.
34:08 Or even worse, like in a day, not many more raised their hands.
34:12 Right.
34:13 The goal here is really like, you can just hop in, click, you know, start a new project.
34:18 It's already conveniently already a Hello World application by default.
34:22 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 and effectively to, it's just a matter of seconds.
34:35 I just need to share the link and then can see, you know, they can see on mobile and things like this.
34:41 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. 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:56 Right.
34:57 Right.
34:57 Right.
34:58 So Python adoption, Python and education, all of those use cases. That's why I really bag everyone. Talk about PyScript. And that's the value of sharing and spreading Python all over.
35:10 Yeah. Let's look at one of these. So if you create an account, you log in, there's a trending in a featured set. So one of these is tic-tac-toe and I'll view the site that we can maybe talk about the code real quick. 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. That was when this time, but it's, it shows the JavaScript interaction, the click down, the changing the DOM from Python, all those good things. Right.
35:44 Yeah. And so you can go view the code for it. Maybe just, we could use this as a chance to just talk through a little bit of like how you're structuring this. Cause you've got a manifest, you've got a main.py, you've got an index.html.
35:58 You come across an app that's written in with pyScript.com and you want to know how does it work? You know, the, the classic, you know, view source, the number of people who said I became a software engineer because in the nineties, when I was a teenager, I could right click view source and figure out what, okay, that's that. Okay.
36:13 So I just wanted to highlight that that was, that was there. Any pyScript.com app, you'll be able to see the, see the source.
36:19 Excellent. And you can copy.
36:20 Yeah. And you also have a copy. Yeah, exactly. We're on the same page. There's a copy of the project, which has got like, like a clone this to my account and I'll play with it. Right. Yeah. Yeah. Yeah, exactly.
36:29 Yeah. That's actually one thing that we've been struggling with terminology, trying to, do we use the usual geek technology, terminology, or we use, you know, user friendly, should we use copy or fork?
36:41 Yeah. Yeah. Yeah. Yeah. Yeah. So tell people quickly about how, what you can do with pyScript.com, kind of how it works. It's a little bit like replet, but really Python focused, right?
36:53 Yes. It's very similar to replet or, you know, code pen 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. 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. And we always have the view of the files, then a preview with an iFrame that you can see your app while you develop and whatnot.
37:29 Yeah. Mm hmm. Quickly about the geography of, of how the project is organized.
37:34 Sure.
37:35 You have your index.html, which is the thing that is first served to the browser. And if we, if we go look at that, we'll see that in there, it's just referencing basically all the other things. And it's just plain old HTML in there as well. So we've got PyScript being loaded as well. We've got some CSS.
37:51 They've got the script, PyScript tag that tells us that main.py is where the application is going to be run from. And then we just have, you know, the HTML code for displaying the user interface. If we hop over to manifest.json, this is an old one.
38:08 The others that have a PyScript.toml, right?
38:10 Yes.
38:11 I was just going to say, it's usually a PyScript.toml file.
38:14 I can pull that up for us here.
38:17 Yeah. Yeah. That's great. In the HTML file, it's going to be empty because there's nothing there, but this is where you, you start to define characteristics of the environment in which this app is going to run. So you might say packages equals, and then a list of packages that you want installed as if it were a requirements.txt file. Okay.
38:38 Give me a sense of what I can put in that list.
38:40 That looks good.
38:42 I know.
38:43 Anything that is pure Python.
38:44 Okay.
38:45 Almost, almost everything.
38:46 Yeah.
38:47 There are, there are complicated caveats, which we could go into.
38:50 Yes.
38:51 Overall, overall, the differentiator is really if you're using anything that does multiprocessing or threading or sockets, right? Like those on the browser don't really exist.
39:01 Right.
39:02 So I couldn't use PyMongo or Pg, Psycho or requests per se, because those are basically violating some.
39:11 Yes.
39:12 Browser.
39:13 Yeah.
39:14 A request specifically there, there is a pipe package that patches requests.
39:20 So you can actually, it's called for Pyodide.
39:23 It's Pyodide HTTP, I think.
39:25 And it basically just patches everything from after you do that, then you can just import requests and use it normally.
39:31 So it does work right now.
39:32 Yes.
39:32 But so the important thing is, is that you remember that your tab is the conceptually equivalent to your virtual inf.
39:40 Okay.
39:41 And so the PyScript.DOML file is just the way PyScript learns about how do you want to configure your environment for this.
39:49 Okay.
39:50 And then if we look in main.py, there we go.
39:52 It's the classic Python.
39:54 This is where you start.
39:55 This is where you just type your Python code.
39:57 Just go ahead, you know, import JS and then JS document dot whatever, you know, to get yourself into the DOM, that sort of stuff.
40:05 Yeah.
40:06 And from that, you have a link that you can share with anyone, right?
40:09 Like it just works.
40:10 Yeah.
40:11 That's the power of it.
40:12 Right.
40:13 Yeah.
40:13 Excellent.
40:14 So yeah, I just got to share or copy it or whatever.
40:16 Yeah.
40:17 So this is a way for people to play with PyScript.
40:20 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:37 Yeah.
40:38 That's actually a great question because we've been discussing that a lot.
40:41 And hey, just we should actually, should we remove latest and or unstable?
40:46 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 going to change things under the rug for you and your app just works.
41:05 It's been courteous to the user, isn't it?
41:07 I mean, we don't want to do something that breaks their code.
41:10 Okay.
41:11 So if you pin it to, you know, PyScript version 0.0.1 alpha one, you know, from way back when dinosaurs ruled the world, but your code still works.
41:19 It might not be the most up to date PyScript, but it's your code.
41:23 It's your responsibility.
41:24 If you want to update the runtime, you go knock yourself out.
41:27 We need to do something.
41:28 That's a good idea.
41:29 So that brings up a bit of a comment from Toon Army out there who says, so we're just about out of alpha.
41:36 Do not use in production question mark.
41:39 Yeah, that's a good idea.
41:40 What's the status?
41:41 YOLO slash latest.
41:44 Let's go.
41:45 Backwards.
41:46 So even with very stable things, I would always recommend pinning all the versions anyway.
41:52 Right.
41:53 I can.
41:54 And even the secondary versions and whatnot, 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 and just use best practices.
42:11 For instance, we are using config and PyConfig and PyScript with source and not having code in line, right?
42:18 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:28 So we're saying just let's just use templates that are encouraging best practices and pinning the versions is one of them.
42:34 Could I write unit tests?
42:35 Could I have a page that is like test.html and then import pytest?
42:40 I do that.
42:41 And you start running the browser.
42:42 Yeah.
42:43 Yeah.
42:44 So, okay, here's the thing.
42:45 And we've not mentioned PyPicard or InventWat, 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:58 That's the context literally in which this code is supposed to run.
43:01 So let's run the test suite in the browser.
43:04 And it just works.
43:05 It's lovely.
43:06 Yeah.
43:07 It's a good idea to actually seeing the thing.
43:11 A real kind of woohoo kind of fist pump.
43:14 Yeah, that's fantastic.
43:15 So speaking of you, why don't you?
43:17 Yeah, I just want to mention one aspect, which is we don't always think about this.
43:22 Because PyScript runs in your browser, in your clients, like there's no server side logic or anything like this.
43:29 So scalability comes for free.
43:31 You can scale your Hello World app to a billion users and not notice.
43:37 Because all the computation is going to run on their end.
43:40 Right?
43:41 Which is another really cool aspect of the whole thing that we don't give enough credit to it.
43:46 But it's important.
43:47 Yeah, it absolutely is.
43:49 Unless you have some kind of server sync type of thing.
43:52 There's just there's no effort.
43:54 Right?
43:54 Yeah.
43:54 Other than delivering the wasm bits.
43:56 Yeah.
43:56 All right.
43:57 Somewhere buried in here, we have Piper card.
43:59 There we go.
44:00 Okay.
44:01 So you mentioned you were working on this.
44:03 Tell us about this, Nick.
44:05 Okay.
44:06 So Peter, when he announced PyScripts the world at PyCon last year, he said this is going to be for the 99%.
44:13 And for that, he meant that not developers.
44:16 Okay.
44:17 And I'm old enough because I'm dinosaur.
44:20 Really in internet time.
44:21 You were on the internet before the web existed.
44:24 I was actually, I was, I remember getting NCSA mosaic onto a 386 machine in my computing lab at university and got it.
44:34 Oh my gosh.
44:35 This is incredible.
44:36 It was mind blowing.
44:38 That's the first graphical.
44:39 I can connect to NASA.
44:41 That's amazing.
44:42 I just said two minutes.
44:43 I'll be able to download this picture.
44:44 It'll be so remarkable.
44:45 Yeah.
44:46 There was Archie.
44:47 There was gopher.
44:48 There was telling us before the web.
44:49 Okay.
44:50 That's a whole different podcast for old fellows who were on the web back in the day.
44:55 We should stop that now.
44:56 We're turning into the full internet.
44:57 Yeah.
44:58 The internet used to have a sound.
44:59 Nicholas.
45:00 Yeah.
45:01 Yeah.
45:02 Oh, yes.
45:03 Yes.
45:04 Anyway.
45:05 Sorry.
45:06 Young people.
45:07 Anyone under the age of 40.
45:09 All right.
45:10 Paper card.
45:11 Back then when dinosaurs ruled the world, there was an incredible framework for writing GUI based
45:21 apps on the early versions of the Mac.
45:23 Okay.
45:24 And it's called hyper card.
45:25 And the concept is very easy to explain.
45:29 The user interface is just made of a stack of cards.
45:32 Okay.
45:33 And there is always one card being displayed at once and you interact with that card.
45:38 So there might be a button or there might be some text or a link or a picture or a movie.
45:42 But when you interact with that, it transitions you to another card.
45:46 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:53 If you want to run away, turn to page 32.
45:56 So you transition to a new state.
45:58 That's a new card or a new piece of text in the adventure game as it were.
46:01 And so on and so.
46:02 Okay.
46:03 It's really easy to explain that to 11 year olds.
46:05 Okay.
46:06 And so we took that pipe a 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:24 You just have to have patience because it takes 10 seconds to auto advance.
46:27 Yeah.
46:28 Okay.
46:29 So that, so these demos allow me to, you know, exercise different aspects of the underlying browser and how that interacts with Python and things.
46:37 But what we've done is we've renamed it from a Piper card because that has a legacy.
46:43 People think it's going to be hypercard when in fact it's not hypercard.
46:47 It's actually Python in the browser, but we use that card like metaphor, but there are other things that we kind of, we want to build into that.
46:54 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.
47:18 It'll all look the same.
47:19 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 end up in PyScript.com that will allow beginner coders in the same way that, you know, my work on Mew tries to give you a code editor.
47:38 That's not as complicated as a Visual Studio Code, but it lets you get to the good stuff as quickly as possible.
47:43 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:56 So we should see Piper Card as kind of a proof of concept and then you're coming out with this, you called it Invent.
48:03 Invent.
48:04 So you literally import Invent and then import dot app or import dot whatever.
48:09 Yeah.
48:10 Not import.
48:11 Invent.
48:12 Yeah, yeah, yeah.
48:13 In the end of the day over here in the UK.
48:15 I'll say one thing to you, Nicholas.
48:16 Actually, I'm a little disappointed, to be honest, that I'm the only one that actually is dogfooding type Invent and writing my talks with Invent and all of those.
48:27 Yeah.
48:28 You should please.
48:29 For Pi.
48:30 Hey, it's great.
48:31 I've been using actually visual Pi script and Invent, et cetera, for my talk.
48:36 And I was expecting you would say like, yeah, me too.
48:39 They're like, oh, really?
48:40 Really brave of you.
48:42 Just left you hanging out.
48:45 Yeah, yeah.
48:46 I have a bank to rights.
48:48 He's got me bank to rights.
48:49 But honestly, one thing that I didn't think before while in the Uber to the conference the day before my, no, 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, which is it helps to the power of the framework itself.
49:10 Yeah.
49:11 Kudos.
49:12 So you've told a good, really good story here, because now imagine that you are in a classroom in, I don't know, I'm just picking random kind of in Mexico.
49:20 Okay.
49:21 And you've got a class where there are kids with Chromebooks.
49:23 Okay.
49:24 Getting Python on there, getting any app to be built on those is difficult enough.
49:29 Like with PyScript, it's going to be so much easier to sort of stories to do that sort of thing.
49:36 Mm-hmm.
49:36 So that's, we're working hard on that.
49:39 And it's going to be a long journey, but we're confident that it'll, it'll produce good results.
49:43 Do you have some dreams or have you thought about Git and GitHub integration into PyScript.com?
49:50 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:58 Yeah.
49:59 Go ahead, Nikos.
50:00 I was going to say, I look forward to the feature request on our, you know, we're listening to the community.
50:09 If that's something that you want, tell us about it.
50:11 Yeah.
50:12 Actually, I would love to hear more about how would you, people would envision it.
50:16 So we already kind of already have it in the sense that people working on both PyScript.com, but also the OpenSearch project.
50:24 We, we have a, a CLI for both, right?
50:27 And 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:34 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 on .com.
50:46 And one of the first scenarios that we're thinking was, as a developer, probably not as a, as a non-technical user, but as a developer, I want to use GitHub for my virtual control things.
50:57 And I want to use PyScript.com to deploy and change things.
51:00 So we do have a minimal integration.
51:03 We're going to be announcing and properly announcing and releasing those things in a month timeframe.
51:09 Nice.
51:09 You know, that is one of the most important use cases that we have.
51:13 Yeah.
51:14 Take my thoughts for what they are is, you know, very loosely informed, not a lot of skin in the game, but you know, with my, my website, my personal website, I use Hugo.
51:25 And then I just push to a branch that triggers a deploy on Netlify.
51:29 You know, there's kind of the Heroku type thing, right?
51:33 It'd be cool if it kind of just like, it goes to this branch.
51:36 That's what's on PyScript.com.
51:38 If that's what I would love if I were doing the integration and using it, but yeah.
51:42 Yeah.
51:43 And that's one use case.
51:45 Interesting that you mentioned, we've been looking at Heroku as well, et cetera.
51:49 That kind of difficulty here is we're often used to a one repo, one app type of separation.
51:57 But you may have like a one repo where let's say you collect all your talks over and that you give, you know, around conferences.
52:04 And you may, you may want to have a folder and each folder is one app on PyScript.com.
52:08 And how do we support those, you know, different workflows?
52:11 That's the type of thing I'm thinking right now.
52:14 And that, that is sure.
52:16 Well, people who are using, using it, you know, reach out to these guys and give me your thoughts here.
52:21 Thank you.
52:22 We're getting, of course.
52:23 Yeah.
52:24 Maybe the last thing we should talk about is kind of PyScript next.
52:28 Where are we going from here, folks?
52:30 Yes.
52:31 So let me use this real quick.
52:32 And I think, I think you should have like a link to-
52:35 I have a bunch of tabs open.
52:37 That one.
52:38 Perfect.
52:39 So what's PyScript next?
52:40 It's, as I said, like we're rewriting PyScript 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:51 So y'all listening.
52:53 It was awesome.
52:56 I'm sure the release was amazing and it went really well.
52:59 So perfect.
53:00 Congratulations.
53:01 That's very doctor who of you to say that.
53:04 Yeah, it is.
53:05 But the gist of it is that we rethought a lot of the core concepts and now we are allowed, we have, we're able to allow multiple interpreters.
53:15 We have MicroPython by default, supported by defaults.
53:19 All of the interpreters support execution on the main thread, just like the previous version of PyScript.
53:25 But now also you support on a worker, web worker, which means you can run Python while the web is loading or while the page is doing other things.
53:36 It's like there's another process or other processes in your page.
53:40 That's what basically a web worker is.
53:42 All right. That's been a big part of WebAssembly for quite a while, but you all haven't leveraged that previously, right?
53:47 Yes.
53:48 Yeah.
53:49 And it was very painful for us because, you know, for instance, panel and internal projects of Anaconda, like they, they have all the examples ported to the web with Pyodide.
53:58 And because we didn't support the workers yet, it was better for them to just use Pyodide directly.
54:04 Now we can allow them to use PyScript and, you know, do all those things.
54:08 We saw actually a type preview of even Django or FastAPI running on PyScript with workers, right?
54:15 Like, which is extremely cool.
54:17 And you can think of, it's hard to actually imagine, but even just the educational purpose of this, you can have wide running examples in your docs and you can just play with it, which is interesting.
54:30 Well, I don't know how, how well PyScript plugs into this world, but there is an entire ecosystem that I don't operate very much in.
54:38 But where you, if you had a, if you have WebAssembly, you can run it kind of like node can run JavaScript on a server.
54:44 You can run WebAssembly stuff in the cloud on a server in a container, or you can run it directly.
54:50 So in those scenarios, it makes tons of sense to say we're going to use PyScript to host FastAPI.
54:55 And it, it has a meaning, right?
54:56 It, it's not just browsers all the way down or something, right?
55:00 It's, it has a purpose for being there.
55:02 Yeah.
55:03 Yeah.
55:04 And I, well, I wish we had more time.
55:05 I had, there's a lot going on in WebAssembly ecosystem as, as well to support this as well, which is cool.
55:10 Yeah.
55:11 But just in the interest of time, we, this next branch as well, it also supports communication between workers and the main thread and vice versa.
55:19 So, and we can have multiple interpreters.
55:22 Maybe one is Pyodide, another is Python, another is Lua.
55:26 And we have examples of those that then they can communicate between each other, right?
55:31 Like if you click on all together.
55:33 Okay.
55:34 So you've got JavaScript starting MicroPython in a WebWorker.
55:38 Okay.
55:39 And then MicroPython saying hello back to JavaScript.
55:42 But at the same time, MicroPython on the main thread has actually started in a WebWorker, 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 WebWorker.
55:59 And then when CPython has loaded and everything back to the MicroPython context, you know, hello MicroPython.
56:05 This, you know, can you imagine?
56:07 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.
56:19 And they would like, they would want data where they would, they wanted to grab data, then run, run it through some R thing.
56:25 And then run it through some Python thing.
56:27 And then stick it on a browser, you know, on a website somewhere.
56:30 So some minister or a highfalutin civil servant can go and have a look at the graph of, I don't know, COVID.
56:36 The spread of COVID through the UK prison system or something like that.
56:40 Well, you can do that all in a single browser.
56:42 The amount of stand on one leg, stick your finger in your ear and whistle, God save the king backwards.
56:47 You needed to get that to work was, you know, it took them weeks to just get their development environment set up.
56:53 With Web Workers, we've, and the multiple runtimes, we've kind of got that as a solution in now as well.
56:58 Actually, the speed of loading speed.
57:02 Like you didn't, we didn't have a loading stream.
57:05 We didn't have like, actually, if you check the network.
57:09 Let me try the map plot live.
57:11 Yeah.
57:12 Or just try my microphone and see how fast that brings you up.
57:15 This one.
57:16 Yeah, there we go.
57:17 I mean, it's like instant.
57:18 Yeah, it is instant.
57:19 It's amazing.
57:20 Yeah.
57:21 And once it's cached, it's, you know.
57:23 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:30 Yeah.
57:31 Actually, the last one that I wanted to show actually is the next tab that you have a thing, which is, there you go.
57:38 Can you open the console as well?
57:40 Thank you.
57:41 Should use my little hockey thing here.
57:42 My little, is it like a hockey you can do to open those?
57:45 Anyway.
57:46 Yeah. Okay.
57:47 If you go to console, actually, just to show the results.
57:49 Yeah.
57:50 Perfect.
57:51 So this example is actually having, it's a Python input keyword stopping its execution, waiting for an answer.
57:59 Oh.
58:00 So it's actually blocking calls.
58:01 You're good at math.
58:02 Seven.
58:03 Right.
58:04 No, no, no, no, no.
58:05 That's the JavaScript console.
58:06 You want to type seven into the input.
58:08 The input.
58:09 Okay.
58:10 So basically what's happening is it's blocking and then waiting for its goal while the page is still responsive and everything else.
58:18 And then when you answer, it executes.
58:20 Mm-hmm.
58:21 Okay.
58:22 Because that unlocks a lot of use cases.
58:24 But debugger, for instance, like we can have breakpoints somewhere and you can go and debug your code.
58:30 And a lot of scenarios that were not working before can work now.
58:35 So this is very exciting.
58:36 You know.
58:37 Yeah.
58:38 There's a lot of kind of under the hood stuff that has changed that enables us to do some really cool things.
58:42 Yeah.
58:43 Excellent.
58:44 So with the web workers, do I get async and await?
58:47 Yes.
58:48 And proper async and await.
58:49 Yes.
58:50 That's fantastic.
58:51 Okay.
58:52 All right, guys.
58:53 What else?
58:54 What final things do you want to tell people before we wrap up this PyScript update episode?
58:59 I've got two things.
59:01 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:08 And our colleagues who work on that have done an amazing job.
59:12 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:22 So knock yourself out.
59:23 Go and go and do that.
59:24 And the second thing I want to say is that PyScript is open source software.
59:28 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:40 Build a framework on top of PyScript, build plugins on top of PyScript, create a goofy app on top of PyScript, you know, put it on your Tesla or whatever.
59:47 You know, I don't know.
59:48 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.
59:58 And, you know, I go, wow.
01:00:00 Like I said, I never thought someone would do that.
01:00:02 That's be playful, explore, be creative, have fun.
01:00:05 That's what I want to see.
01:00:07 That's what I want to see.
01:00:08 I don't know, Fabio, how about you?
01:00:09 Yeah.
01:00:10 I would actually just double down what you said and actually encourage everyone to reach out.
01:00:16 We were trying to make it a good tool for anyone to learn programming or to share your things, et cetera.
01:00:23 And a lot of the difficulties we have all the time is trying to think with new users' brain or, you know, a student's brain and people with different backgrounds.
01:00:36 Because unfortunately or fortunately, we've been in this game for 20 years.
01:00:40 Right.
01:00:40 So it's really hard.
01:00:41 So what we say, reach out, we need you.
01:00:44 We really mean it.
01:00:45 Like, yeah, we, I think I strongly believe that all open source projects are about people and benefit from the diversity.
01:00:55 Right.
01:00:55 Like, good docs are made by non-developers.
01:00:58 Good, you know, good content is made by, you know, people that have passion for hopping on a video and talking about the stuff.
01:01:08 And I'm trying to convince my daughter to have like a PyScript channel on TikTok, you know, just to talk.
01:01:13 Oh, that'd be cool.
01:01:14 Yeah.
01:01:14 Right.
01:01:15 To talk the lingo.
01:01:16 So we really value you reaching out and coming and helping us be more, you know, human as a project.
01:01:23 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:32 So, 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:48 So, yeah, that's all I have.
01:01:50 I wanted to say.
01:01:51 Yeah. Excellent.
01:01:52 Maybe a quick final question.
01:01:53 Marwan says, any work on the HTML canvas via PyScript?
01:01:56 Thinking of simple stuff like creating a snake game.
01:01:59 Okay.
01:02:00 So, everyone import JS.
01:02:02 Now you have global this.
01:02:03 Okay.
01:02:04 Now you have access to your canvas.
01:02:06 And it's the same API because we're proxying the JavaScript objects as you'll find on like the Mozilla, you know, developer docs.
01:02:14 So go knock yourself out.
01:02:15 Awesome.
01:02:16 Yeah.
01:02:17 That's what I imagine.
01:02:18 MDN network, W3 schools, if you can choose.
01:02:21 Yes.
01:02:22 Yes.
01:02:23 I'm also working on a higher level of web API for PyScript, which will help with that as well.
01:02:29 Make it the API more Pythonic.
01:02:32 But what they call that is available today.
01:02:34 And you can just, you know.
01:02:35 Yeah.
01:02:36 And you get to reuse your JavaScript skills if you have.
01:02:38 Yeah.
01:02:39 It's the same API.
01:02:40 It's the same API.
01:02:41 Yeah.
01:02:42 All right, guys.
01:02:43 Thank you for being here.
01:02:44 Thank you for this project.
01:02:45 It's really, really exciting.
01:02:46 And I look forward to catching up again and seeing what else you've built in six months, three years, whenever it turns out to be.
01:02:53 Yes.
01:02:54 And thank you, Michael, for this and running the show.
01:02:57 This is always a great fun.
01:02:58 Thank you.
01:02:59 Thank you.
01:03:00 Yeah, you bet.
01:03:01 Bye.
01:03:02 Bye.
01:03:03 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,
01:03:21 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/donewithpycharm.
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
01:03:40 Sentry.
01:03:40 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:50 We have one of the largest catalogs of Python video courses over at Talk Python.
01:03:54 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:02 Check it out for yourself at training.talkpython.fm.
01:04:05 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:11 You can also find the iTunes feed at /itunes, the Google Play feed at /play,
01:04:16 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,
01:04:27 be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
01:04:32 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:38 I'll see you next time.