2 ms·
Yes, 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 f
by hot_gril 4y ago
Yes, 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.