Python in the Browser - Run! Run! Run!
Praveen Sridhar (~psbots) |
Wouldn't it be great if your blog readers could run and play with the code right away?
Fancy running Jupyter-like notebooks entirely in the browser without any server?
This talk will get you a headstart into running Python directly in the browser.
Introduction (2 mins)
- About me
- Why the Browser is an important stack to target?
Three major approaches
We will be peeking at the different approaches that have been taken to target Python on the browser and compare and contrast them by digging deeper into how they work under the hood. Brief details below :
This has the advantage of having pure JS as a final output, without any need for a large file to be loaded on the browser. However, the implementations are not feature complete with the Python standard and introduce different ways to handle JS quirks.
Examples include PyScript and Transcrypt
Skulptwas very successful in using this approach as a teaching tool, where students could run their scripts directly in the browser based online course. Another project that uses this approach,
Examples include Brython, Skulpt and Batavia
Web Assembly (6 mins) - Converting full implementations of Python to run on the web
Examples include PyPyJS and Pyodide
Conclusion (5 mins)
- Is there a single best way to go about this problem?
- Learnings about Python internals
- This area is still in its infancy - what to look forward to?
General overview of how Python works under the hood - What happens when you run a Python file using CPython, what Python bytecode is etc.
Currently working as a Freelance Python Developer based in Kochi. Originally did Bachelors in Mechanical Engineering from CUSAT. I have completed consulting projects in ML and AI with multiple startups and companies. My work on CNNs was the winning solution for IBM’s Cognitive Cup challenge in 2016 and gave a talk on the same at the Super Computing conference SC16 at Salt Lake City, Utah : Slides
Previously I was a Technology Innovation Fellow with Kerala Startup Mission where I started a non-profit student community TinkerHub, that has a focus on creating community spaces across colleges for learning the latest technologies.
I've been dabbling around with browser technologies since my college days since 2011 being a Mozilla volunteer which got me interested in finding ways to run Python in the browser.