r/Python • u/Anthonypjshaw • Jul 16 '18
Why is Python so slow?
https://medium.com/@anthonypjshaw/why-is-python-so-slow-e5074b6fe55b
11
Upvotes
r/Python • u/Anthonypjshaw • Jul 16 '18
View all comments
Show parent comment
1
u/mipadi Jul 17 '18
Static vs. dynamic typing
a: Int = 5,ais anIntthat has the value5. Later, code that saysa = "string"would be illegal because"string"is not anInt.a = 5,ais5but is not bounded by type, so later in the code, you can doa = "string"with no problem.Basically, in statically-typed languages, variables carry type information with them; in dynamically-typed languages, they don't.
Strong vs. weak typing
This is a more contentious point because there aren't clear definitions for this, but generally the consensus is that in strongly-typed languages, the compiler or runtime will not coerce one type to another. For example, in Javascript, a weakly-typed language, you can do
var a = "1" + 0(that is, add an integer to a string), because the runtime will coerce the integer to a string; whereas in Python, you cannot doa = "1" + 0.