4 ms·
This might be a difference of semantics- there is a difference between garbage collection as a concept being slow and python's GIL approach. My understanding is
by mattnewton 4y ago
This might be a difference of semantics- there is a difference between garbage collection as a concept being slow and python's GIL approach. My understanding is that the GIL would almost always make the top 3 reason of why python is slow in practice - it works for a very specific single threaded execution model but can't really take advantage of modern processors.
- slt2021 4y agoI think GIL is not the reason for slowness, it just specifies single threaded interpreter execution model. You can always spin up more interpreters to take advantage of multiple cores. The reason for slowness - is the weak dynamic type system of Python. Every single instruction need to be type checked at runtime and thus making everything slow. Compare to C#/Java which have GC but both are amazingly fast, because these languages have stricter type system. If you add JIT on top (which can selectively replace MSIL/java opcodes with native machine instructions) and it makes perf on par with natively compiled languages like C++.
- kstrauser 4y agoI'd argue Python is strongly, dynamically typed, and that "weak" and "dynamic" are on different axes.
- deleted 4y ago[deleted]
- dymk 4y agoIt's always interesting how often people confuse the dichotomy of "strong/weak typing" with "static/dynamic typing". They are orthogonal to each other indeed - you can have languages that are in each of the four possible combinations.
- PartiallyTyped 4y ago> I think GIL is not the reason for slowness, it is the weak dynamic types of Python that make it slow. Python is structurally typed, that makes it dynamic, but it is not weak as there is no type coercion. > Every single instruction need to be type checked at runtime and thus making everything slow. This is also wrong, python does not type check anything, not in the "regular" manner of typechecking. It relies on structural typing, if it quacks like a duck, then it is treated like a duck. In fact, PyPy is an argument against your position as it still allows the same (more or less) behaviour that python has while operating a lot faster due to JIT. Python doesn't have the luxury of compiling that C# and Java, nor is the VM intended to be high performing.
- pjmlp 4y agoPyPy is still slower than the competition and largely ignored by the Python community.
- riku_iki 4y agoalso, is py still interpreted or jit-compiled?
- nicoburns 4y agoI believe the main reason Python is slow is because the cpython project has rejected performance enhancements in favour of keeping the code simple. JavaScript has similar semantics to Python, and its performance is not far behind Java/C# at all.
- orf 4y agoJS has vastly different semantics to Python, one that lends itself much more to the kind of JIT optimisations needed to make it more performant.
- fwip 4y agoWell, the author went on to rule out Java and Go because they garbage connected, so I don't think they meant the GIL.