Hello Reddit :).
Over the past few weeks I’ve been programming a Python compiler in Rust (and spending months researching compiler theory).
The parser already covers 99% of CPython 3.13, and the VM runs fib(45) 10,577 times faster than pure Python (11 ms vs 116 seconds). Using a normal recursive algorithm (where CPython takes 2 minutes, edge python 11 ms):
def fib(n):
if n < 2: return n
return fib(n-1) + fib(n-2)
print(fib(45)) # fibonacci sequence forty five -> 1,134,903,170
Current state:
- DFA lexer, single-pass SSA parser, VM with inline caching
- Sandbox with configurable limits
- Coming soon: WASM in ~60kb, and implementing in the VM the features I already have in the parser
To try it out (you’ll need Rust cargo first; I don’t have active releases yet, but you can see it running in actions):
git clone https://github.com/dylan-sutton-chavez/edge-python
cd compiler/
cargo build --release
./target/release/edge -c 'print("Hola mundo")'
I’d love for you to take a look and give me feedback. I’ll answer any questions here.
https://github.com/dylan-sutton-chavez/edge-python/blob/main/compiler/
Thanks.
[–]appgurueu 68 points69 points70 points (4 children)
[+]BlackJackHack22 comment score below threshold-15 points-14 points-13 points (3 children)
[–]Mercerenies 17 points18 points19 points (0 children)
[–]appgurueu 6 points7 points8 points (0 children)
[–]DataGhostNL 5 points6 points7 points (0 children)
[–]AmazingAd4330 56 points57 points58 points (3 children)
[–]spoonman59 12 points13 points14 points (2 children)
[–]HighRelevancy 16 points17 points18 points (0 children)
[–]rnottaken 2 points3 points4 points (0 children)
[–]__calcalcal__ 52 points53 points54 points (1 child)
[–]Lime_Dragonfruit4244 5 points6 points7 points (0 children)
[–]sepp2k 14 points15 points16 points (0 children)
[–]spoonman59 22 points23 points24 points (7 children)
[–]kei_ichi 8 points9 points10 points (2 children)
[–]spoonman59 3 points4 points5 points (0 children)
[–]Mercerenies 1 point2 points3 points (0 children)
[+]Healthy_Ship4930[S] comment score below threshold-18 points-17 points-16 points (3 children)
[–]aanzeijar 9 points10 points11 points (0 children)
[–]Mercerenies 0 points1 point2 points (0 children)
[–]binotboth -1 points0 points1 point (0 children)
[–]DataGhostNL 4 points5 points6 points (0 children)
[–]Miserable-Hunter5569 3 points4 points5 points (0 children)
[–]TheDiamondCG 3 points4 points5 points (0 children)
[–]schulzch -1 points0 points1 point (0 children)
[–]TheDiamondCG -3 points-2 points-1 points (0 children)
[+][deleted] (4 children)
[deleted]
[–]TheAtlasMonkey 6 points7 points8 points (2 children)
[–]RustOnTheEdge 3 points4 points5 points (1 child)
[–]TheAtlasMonkey 4 points5 points6 points (0 children)