4 ms·
There are certainly languages that it is essentially impossible to implement to run fast. Like, one can certainly write a slow C... but writing a fast Python (
by TylerE 7y ago
There are certainly languages that it is essentially impossible to implement to run fast.
Like, one can certainly write a slow C... but writing a fast Python (real Python, I mean, with full reflection, run-time introspection, etc..) would be...near impossible.
Yes, I know there are projects that make large subsets of Python run fast, but it's that last 5% that kills you.
- nerdponx 7y agoFWIW PyPy is signfificantly faster than CPython in a lot of tasks.
- marcosdumay 6y agoPyPy doesn't support a lot of CPython's reflection and introspection. to see the problem with Python, take this loop as an example: x = 0 for i in range(0,1000): x = x + i There is no way, looking only at this part of the code to know if the `+` operator does the same operation every time it is executed.
- nerdponx 6y agoWouldn't that require some code to redefine `int.__add__` or `int.__radd__` between iterations of the loop? Which I would file under "bizarre shit that shouldn't normally happen." Before the loop starts, you'd have to override `int.__add__` to modify itself every time it's called, or something crazy. If we're talking about custom classes and not ints, maybe it's a bigger problem. But if PyPy doesn't allow the required introspection to make this work, how does it run anything at all?