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