Why I built another Python for the edge (and how it differs from MicroPython)

When I started programming Edge Python more than six months ago, I was looking for a version of Python that weighed less than 200 kb so it could reach any device, sandboxed by design, built with browsers in mind, decoupled from the operating system and very fast.

Today the closest competitor would be MicroPython. However, it did not solve my real problems or the problems of the people who use the project.

  • Managing async and blocking code on the event loop. MicroPython inherits CPython’s blocking execution model, designed around the GIL. When I built Edge Python I put the events inside the virtual machine, and that lets you run any operation while handling thousands of connections without blocking the main thread or the worker’s thread.
  • MicroPython was not built for the web and neither was its stdlib. I have been working to get regex and every other dependency down to a few clean lines, crash free thanks to directed fuzzing.
  • Edge Python guarantees parsing everything in linear time, in a single pass, while MicroPython does not. This came from avoiding a syntax tree, which makes programs parse faster.
  • MicroPython crosses into JS through PyProxy. Edge Python avoids that entirely with an execution model decoupled from the host, they never have to interact directly.
  • I recently added the ability to serialize entire programs, born from an issue. If a user closes the tab, the whole bytecode state gets serialized, stored in the browser cache, and when the user comes back execution continues from the exact same point.

That said, my intention was never to replace CPython and it never will be. It has a gigantic ecosystem and competing with it is not even a priority for me. What I want to enable is this.

  • Anyone with business logic written in Python being able to run it on the client side.
  • Running lightweight LLM logic on the client side, so you do not need expensive compute just to parse a CSV or do math.
  • Building a framework to run lightweight machine learning models entirely on the user’s side.

I am still working on all of this and, to be honest, I do not know how long it will take me to reach a real version to build a product around. I just want to say it has been an incredible process, and it has made me realize that with a compiler of barely under 20,000 lines I spend less and less time writing code and more time automating its stability with fuzzing and determinism.

Thanks! Any feedback or experience is appreciated. If you want to take a look, try the demo in the browser at edgepython.com and edit the code, the compiler is really fast. Try the CLI version too.

okay it’s different from Micropython because it has goals that Micropython never had.

is this an LLM output that claims you need an LLM to parse csv or math?

Agreed, it was never MicroPython’s principal goal. But saying it never had that goal isn’t accurate either: if you look at the MicroPython repo, its creator has been working on a WASM port for a long time now.

As for the LLM jab the point wasn’t that you need an LLM to parse a CSV. Believe it or not, there are countless SaaS products today spinning up serverless functions and VMs just to process basic CSVs and a thousand other trivial tasks. I’ve talked with plenty of people interested in the engine for exactly that reason the idea is to run that logic on the client so you don’t need server-side compute for simple work.

To be honest the original sentence was poorly worded on my part

I’ve been interested in this project for a while, but this post just muddies the waters further, and makes so many bold claims, I’m instinctively sceptical about them.

For full CPython including C libraries etc. on the web, isn’t Pyodide the strongest competitor? Admittedly it can require a 10-20MB initial download, but that’s not unreasonable these days, especially for Python playgrounds. It usually downloads before I even realise what’s going on.

What’s the significance of the 200kB download size? It’s great it’s <1MB, and so small. But many websites will be even bigger than that without thinking twice, and the ones that do want it that small, will appreciate it being even smaller.

And why the obsessive comparison to MicroPython? MicroPython deliberately cut a lot out from CPython to target microcontrollers (i.e. not the web), and has a fantastic little sub-ecosystem.

You’ve built a new thing that’s a great Saw or Hammer. Great. Well done. But you’re claiming it’s much better than MicroPython, when MicroPython was a Screwdriver all along.

What’s EdgePython cut out from CPython, to achieve an even smaller bundle?

You even claim EdgePython is able to “run LLMs clientside” ? What?!! What size of LLM are you actually talking about?

If I’m running an LLM that’s worth typing those three letters, even one that can run in my browser, then I’m not remotely worried about a 20MB Python download.

[Edit] It’s Python without the stdlib. And imports need special treatment.

It is interesting, and you can definitely write some Python especially for EdgePython. But it’s not a drop-in replacement to run existing code in.

Agree and I never said that, you can read what I say; “That said, my intention was never to replace CPython and it never will be. It has a gigantic ecosystem and competing with it is not even a priority for me. What I want to enable is this.”

And stdlib doesn’t need special treatment I made the full resolution at the host-side.

The last Python subset I heard of is Starlark, initially designed for Bazel (later used by Buck too). I can’t comment on it since I never used it, but it gave me an idea that Edge Python can be used as a scripting engine.[1] Does OP have this vision?

Same question, is OP talking about calling LLM APIs instead? (These are nothing more special than HTTP)


  1. Starlark isn’t even Turing-complete, and the spec says this is to serve its purpose as a configuration language instead. ↩︎

I’ve been interested in this project since it was announced earlier, but it’s very hard to sift any substance out of these posts or the website.

It’d be nice if the documentation was expanded to describe how the thing worked, as if to someone who isn’t familiar with all of the jargon and hasn’t read the references. And it’d be nice to do a deep dive on one of the revolutionary bullet points above, to explain what the gain is.

What does it mean to get regex (or any other dependency) down to “a few clean lines”?

Hi Dylan,
I’ve now had a good play with Edge Python. I got Claude to write a JS script to run compiler.wasm from NodeJS without the Edge CLI - and I do actually really like it. But kind of following on from what you’re saying, in its current state, I can easily imaging using EdgePython to even run any serious pure Python code, could be extremely frustrating.

I stripped down CPython’s test suite to only consider tests that don’t require the standard library. Unfortunately in the end, even after reducing ~1200 tests to ~200, I couldn’t even run those remaining (as there was no dir to find the test methods, and neither vars nor __dict__ fixed it -it was a good excuse for me to use ast though). In doing so I came across the following issues, which I’m sure you’re well aware of. EdgePython would be so much better if these features were implemented (subclassing Exceptions in particular):

  • No dir

  • Unimplemented standard exceptions (UnicodeEncodeError)

  • Adding Bytes (“unsupported operand type(s) for +: ‘bytes’ and ‘bytes’”)

  • Default Hash (object.__hash__)

  • kwargs for classes & metaclasses

  • bytearray

  • Soft keywords (match, case, & type)

  • subclassing Exception, int, str, list, set & frozenset

  • except*

  • Generics

  • Indexing / Walrus

  • Unpacking

  • Complex Literals (imaginary numbers)

  • Slicing / Matrix Multiplication ( @ )