3 ms·
Python is a great example of a compiled language for things like this. It's "known" that it's an interpreted language. Because it allows monkey patching and the
by JonChesterfield 4y ago
Python is a great example of a compiled language for things like this. It's "known" that it's an interpreted language. Because it allows monkey patching and the like it's also challenging to statically optimise in a compiler. Yet cpython leaves compiled bytecode files scattered around on disk so most python programmers will also have wondered "what are these .pyc files" at some point.
It then gives you tooling to poke around the bytecode which is clear enough that you can read it. I once gave a talk showing x64 and bytecode side by side for some arithmetic function and if you pick the example carefully they line up well.
Then there's cython and pypy to point to for different points in the design space than cpython, or jython if you want to talk about the jvm. There's probably one on .net and iirc truffle has an implementation as well. The abandoned unladen swallow. So there's loads of python implementations all approaching the interpreted vs compiled tradeoffs differently.
- hot_gril 4y agoYes, you can still optimize around Python that way. The big difference in end result vs C comes from how Python prioritized runtime flexibility, while C aimed for speed by ensuring the compiler knows more about the program execution beforehand (mainly the size of every variable). The difference is most obvious looking at arrays of fixed-size integers, where a C int* far outperforms a Python list of ints no matter the implementation. Python list is actually a different thing because it has variable-sized integers and can take other objects too, so you can't optimize around that but could do so with a more specific fixed-size int array interface... which is what NumPy did.