4 ms·
No. But that doesn't necessarily help. A straight-forward Python to C 'compiler', which emits the code equivalent to running the VM main loop, has no significan
by dalke 15y ago
No. But that doesn't necessarily help. A straight-forward Python to C 'compiler', which emits the code equivalent to running the VM main loop, has no significant performance increase. You have to do a lot more work (e.g., ShedSkin, Cython) to see better performance.
- unimpressive 15y agoThe idea was that you'd hand hack the performance critical parts. And I believe the correct term is transpiler. (Which can be really useful to have if your language sucks and it'd be easier to edit bad code in a better language. (Or in this case your language is slow and it'd be better to just hack the parts that need to be optimized before you compile the binary.)) Of course; the right thing is to use something like Cython. After all, if you don't get a performance increase anyway you may as well just hand hack the parts you need to optimize as C modules. EDIT: I'm aware I called it a compiler in my earlier post. The transpiler comment was in response to you putting "compiler" in quotation marks.
- dalke 15y agoI put 'compiler' in quotes because I was thinking of a research project a few years back which converted the Python byte code (parsed by CPython itself) into C code, along with a small bit of peephole optimization. I don't think it's worthy enough to be called a transpiler. The generated C code is still a stack machine. You could replace that with C code, but if you wanted to program to a stack machine then you likely wouldn't have been coding in Python in the first place. Part of the nuisance in replacing that C code would be wading through all of the extra code Python generates, just to add two numbers.