| ▲ | gf000 15 hours ago | |
If we are being very pedantic, languages don't have "speed", only implementations do. Of course in the real life there are de facto implementations and language features give way to better/worse tradeoffs. With that out of the way, Python is basically the de facto glue language. It is very often used to provide a scripting API over lower level C libraries. To be ergonomic in this function, CPython (the major implementation) exposed some internal details of its execution model, which C libraries can reach into. This makes it very hard to make more aggressive optimizations, as one example a C library can just increase/decrease the reference count of an object. Another design decision (that got some discussion recently) is the GIL (global interpreter lock) that makes python much less competitive than something like Java. (JS also does a single thread of execution, though there are ways around it). JS has a different use case, so access to the C world doesn't impose such restrictions on it. | ||
| ▲ | mkoubaa 14 hours ago | parent [-] | |
Both you and the grandparent comment are correct. The implementation is slow because the API that it exposes is so leaky that implementation changes (for example a tracing garbage collector) are impossible to implement without changing the API, and the API cannot easily change because of the dependence or the ecosystem on it (e.g. numpy) | ||