3 ms·
Inline Python where all you have to do is put in <python></python>
by thomasjb 1y ago
Inline Python where all you have to do is put in <python></python>
- indigodaddy 1y agoWhat kind of safeguards would we need in place with this sort of feature in html? What are the security implications?
- simonw 1y agoYou can do that today with PyScript: <script type="module" src="https://pyscript.net/releases/2025.8.1/core.js"></script> <py-script> import sys from pyscript import display display(sys.version) </py-script> Demo: https://static.simonwillison.net/static/2025/pyscript-demo.html https://static.simonwillison.net/static/2025/pyscript-demo.h... Or you can use MicroPython which is much smaller: <mpy-script> import sys from pyscript import display display(sys.version) </mpy-script> Demo: https://static.simonwillison.net/static/2025/pyscript-micropython-demo.html https://static.simonwillison.net/static/2025/pyscript-microp...
- dominicrose 1y agoSince they compiled the python interpreter to webassembly, yes you can now totally do a <python></python> webcomponent if you like. Of course it requires the extra work of importing this interpreter. Web browsers aren't going to come with multiple interpreters built-in, it would be too heavy. I would be interested to see how short the time to run "Hello World" can be with python in a webpage, counting the time to load the whole page without cache.
- simonw 1y agoTry benchmarking https://static.simonwillison.net/static/2025/pyscript-micropython-demo.html https://static.simonwillison.net/static/2025/pyscript-microp... and see. It's pretty minimal.