Omyyyy/pycom: A Python compiler, down to native code, using C++
github.com
github.com
https://www.reddit.com/r/Python/comments/w7vlim/i_made_a_pyt...
>c++’s extremely convenient ‘auto’ keyword :)
https://www.reddit.com/r/Python/comments/w7vlim/i_made_a_pyt...
This parses the python and more or less does one for one text replacement. That's a strategy that doesn't scale. It doesn't handle any of Python's dynamic features (x=1, wait, now x="hi" and all the rest), on and on. His claims of 20x speed are based on super simple functions; these numbers will not scale into real scripts/programs. It cannot compile most of the standard lib. It doesn't handle classes, or exceptions. Basically you get simple if/while/for constructs and def func().
His claims that it is faster/better than other mature projects that do work are hubris. Excusable perhaps because of his age, but time to learn.
Lots of assertions on my part, but I'm basing it on this reddit thread: https://www.reddit.com/r/Python/comments/w7vlim/i_made_a_pyt...
Omyyyy, if you are reading this, I'm impressed you got as far as you did, and are continuing to work on it, and don't intend to belittle you. But you are way overselling it and I'm pretty sure you don't understand how you have painted yourself into a corner you cannot get out of due to the simplistic conversions you are doing. Buy a compiler book and start reading!
so what's a good first book for a 15 year old to pick up?
What we need is a rpython suitable for app programming and a stdlib written in that dialect.
https://github.com/py2many/py2many/blob/main/doc/langspec.md
Mypyc ships with mypy and does this. Mypy itself and Black are compiled with it.
I know there is a rich history of projects targeting the JVM, but I could not find anything regarding Python.
Doesn't matter if it is heavily restricted, incomplete, just supports a subset of C or if it is just a research project. All projects targeting the JVM I encountered are like this.
For me it is not so much about a solution but more about the question why apparently everyone is interested in the JVM and no one tackled Python.
1. The JVM executes bytecode much (~10 times) faster than the CPython VM.
2. Unlike the JVM, the CPython VM and bytecode are not compatible with older or newer versions of CPython. (The differences are small, but they add up, increading maintenance costs.)
Pythran is fairly nice, and it really does work. I tried it last year and it compiles down to modifiable templated C++. I was able to use it to build Python for a highly specialized environment.
All the others compile down to dynamically linked binaries, and that just puts them in the "other" box.
Anyway, good luck with project.
The way I think about it is like this, if you want to really just hack something together, why do you care about static typing?
If you're building a serious larger code base, you then might want static typing, so then why not use a statically typed language?
It's been used to build serious large scale projects.
The idea is that you can get great runtime performance by transpiling. This is how Facebook worked till 2013-2014 (php -> C++ transpiler).
It's unfortunate that google abandoned the grumpy project. But many good alternatives around.
Probably the most atrocious code I've ever seen has been PHP followed by Python.
I use Python personally, I just don't think it's a good choice if you really want a statically typed language...because it's not statically typed.