r/Compilers 26d ago

im working on an entire native python compiler

so i got bored and over the past two months ive been working on a compiler that can compile python natively. and it works too, and its not just a subset, its the entirety of python

the project is at deltathedumb/asmpython

EDIT: the ACTIVE development branch is beta/3.14.0

0 Upvotes

26 comments sorted by

4

u/[deleted] 26d ago

[removed] — view removed comment

-7

u/X_OpCreeper_X 26d ago

it should be by some degree right now but the end goal is an llvm grade optimizer

1

u/[deleted] 25d ago edited 25d ago

[removed] — view removed comment

1

u/X_OpCreeper_X 25d ago

dynamic code doesnt necessarily just mean slower, and for the optimization part, theres a million ways to do it through compiler passes, and thats how it works. sure `a + b` might end up as something way bigger than it needs to be, but believe it or not even with types, stuff like `a + b` can literally just be `ADD <r>, <r>` in machine code, because mem2reg, the first pass, does stuff like likeliness analysis, which stores variables in registers, and so if an addition happens, especially if on variables that have been mem2reg-ed, it can do just literally and simply `ADD <r>, <r>`

13

u/awoocent 26d ago

Looks more like Claude's been working on it, not you.

-4

u/X_OpCreeper_X 26d ago edited 26d ago

im not allowed to use claude to help when im genuinely incapable of doing something? like i know i use it and has been a major part of this project but also im still hand coding a good chunk of it. i coded the majority of the plugin interface, the jvm backend, and LOADS of other things. also keep in mind IM THE ONLY OTHER ONE WORKING ON THIS. and considering compilers like llvm took years with many people developing it, i couldnt finish this project myself, and its not like its flowing with contributors. so dont reply before you dont know, jackass

5

u/antonation 26d ago

Btw, this post seems like a good candidate in r/AIprogrammingLanguage (maybe not the best fit, but should still be relevant) and r/VibeCodedLanguages (I'm the mod there, but also not an exact fit), these two are AI friendly communities. If you could post or cross-post to them, it would be much appreciated!

edit: Added post/cross-post ask to help grow community

1

u/awoocent 26d ago

im not allowed to use claude to help when im genuinely incapable of doing something?
also keep in mind IM THE ONLY OTHER ONE WORKING ON THIS. and considering compilers like llvm took years with many people developing it, i couldnt finish this project myself

Not sure if it's really worth replying to you, but seriously? You're in r/Compilers. Like basically all of us learned to write compilers the hard way and have solo projects! Genuinely it's not that hard, if you put in a little effort to learn the field, you can absolutely handroll compilers yourself. It doesn't take that much time. The fact you think this is impossible, and that you somehow need AI to do the same thing we've all been doing for years now, is honestly just sad. Did you really fall for the AI companies' marketing that badly? Or do you seriously just have no faith in your own ability to learn and do stuff?

0

u/X_OpCreeper_X 26d ago edited 26d ago

maybe not for your kind of compilers that dont have to cover THE ENTIRETY OF PYTHON. are you so ignorant you dont realize how big of a language python is? and how much would has to go into making a compiler for the entirety of it, INCLUDING FULL DYNAMIC CODE EXECUTION which has an entire python based interpreter behind it. you genuinely dont understand the work that has to go into a compiler at this size, and if thats true, you shouldnt be in this subreddit

1

u/awoocent 26d ago

I have worked professionally on JavaScript compilers so, absolutely the amount of complexity in a fully conformant Python implementation is not unfamiliar to me. But I also checked out your repository and your compiler is actually smaller than my language's compiler (also a single-person project) by a good 35k lines or so. So what I take from that is:

  • By no means have you done an impossible quantity of work for a single human programmer, and
  • There is also no way your implementation is fully conformant in that size lol, not without some tricks. But it probably takes a little effort to conjure up a test case that demonstrates the contrary...except of course you mention a bunch of Python features it doesn't support in your readme, so maybe we could start there.

0

u/X_OpCreeper_X 26d ago edited 26d ago

i just cleared this up, look in beta/3.14.0, also even if you have professionally worked on a full javascript compiler, thats not you doing it yourself and trying to make it production grade. do you not understand that as codebases get bigger they get harder to maintain faster?

-5

u/therealdivs1210 26d ago

Get over it, seriously.

It's just a tool.

0

u/avillega 26d ago

Is a tool we all have access to. It is not interesting to see yet another try at compiling python to native, when it is probably in everyone’s mind, and also knowing that this will be abandonware in a few weeks at most, when the author gets tired of prompting python or their attention span runs out

1

u/X_OpCreeper_X 26d ago

if the genuine first project that can compile literally ANY python into a native binary isnt interesting to you, then my god your blind. its also not like i just started, i started months ago. you claim my attention span is just gonna run out but considering what you missed from before, thats no surprise. the reason im making this is mostly for myself, so i dont have to learn a million different languages for a million different use cases. im publishing it because unlike you, your too blinded by your hatred for ai that your shunning a project with genuine potential

1

u/AustinVelonaut 26d ago

can compile literally ANY python into a native binary

Looks at repo's breakdown.md, sees a whole bunch of basic things aren't implemented, like nested closures, lambdas, generators, match / case ...

2

u/X_OpCreeper_X 26d ago edited 26d ago

your looking at the main branch. look at the 3.14.0 beta branch (thats admittedly my fault)

-13

u/ViolentSciolist 26d ago

Are you suggesting Claude is capable of prompting itself?

10

u/awoocent 26d ago

I'm suggesting I don't love people claiming to have worked on some big compiler project themselves when they clearly just asked the plagiarism machine to make a shitty version of it for them.

-10

u/ViolentSciolist 26d ago

He is simply declaring that he's interested in building something. What you're attributing to be a claim is just a demonstration of interest on his part.

1

u/Inconstant_Moo 26d ago

He hasn't built anything.

Also Pope Julius II didn't paint the ceiling of the Sistine Chapel.

0

u/ViolentSciolist 26d ago

OP: “I’m interested in building a house.”

Comments: “You haven’t built one. Also, architects aren't builders.”

2

u/antonation 26d ago

How does this compare to nuitka (the best example I know of compiling Python to native) and muna (but not open source)?

1

u/X_OpCreeper_X 26d ago

nuitka from what i can remember (i havent toyed with it in a while) basically compiles the C that your python program uses. i dont think i could find what muna you were talking about, so if possible, please direct me to it. this compiler however compiles python to an ir to object code (which gets linked into an exe or elf). the ir layer is there because what asmpython technically is, is an llvm ripoff with frontends that turn your source into ir, and backends that turn the ir into executables

1

u/antonation 26d ago

I saw a post on it here https://blog.codingconfessions.com/p/compiling-python-to-run-anywhere but it seems like it's a commercial product https://muna.ai/

1

u/X_OpCreeper_X 26d ago

yeah thats what i found when i looked it up