u/ostracizein r/C_Programming • Recommends
On “What makes Python slower than C?”
…r variables whereas in C the programmer tells the compiler exactly how much memory is needed
It turns out “guessing” the type and size of a variable adds overhead when it’s time to use the variable. It can also create a lot of wasted memory leading to unnecessary memory accesses which adds time.
I found this video very helpful in explaining it:
link to this video
That said, Python is better as a sandbox. I recommend using Python until it is clear the input makes it uncomfortably slow. Then it might be time to consider switching to something faster like C.
For most cases, on today’s modern computers, Python is negligibly inefficient and perfectly sufficient.…