4 ms·
You could say the same about JavaScript, but with very heavy investment there are now several implementations that have improved its performance significantly.
by Liquid_Fire 6y ago
You could say the same about JavaScript, but with very heavy investment there are now several implementations that have improved its performance significantly.
Also see PyPy, which manages to squeeze a lot more performance out of Python for many use cases without changing the language.
- awestroke 6y agoJS does not have mutable interpreter frames, global interpreter locks, shared global state, type slots, the C ABI.
- dfox 6y agoJS and Python has essentially same data model with everything being at least conceptually built out of dicts. And well, most JS implementations do not have GIL because they are not multithreaded at all.
- baq 6y agotrue and doesn't matter in the context. you can't change (or inspect) the stack frame as an object. you can kind of look at it with Error().stack. this allows the JS JIT to make assumptions that a python compiler simply cannot.
- dfox 6y agoMost of the things that real application code (ie. not something like debugger) can accomplish by modifying or event inspecting frame objects are going to depend on various things that are documented as CPython implementation details. Also JS runtime that supports some kind of debugger interface has to solve the same class of problems. And the most straightforward solution is not even that complex: you simply have to track when some kind of assumption gets broken and then fall back to interpretation or recompile the relevant code (the most complex part of that probably is converting the native stack frame back into interpreter stack frame, which you have to be able to do anyway in order to even expose it to user code for it to be able to modify it). In fact I think that there are many relatively simple modifications that would make CPython significantly faster, but many such things conflict with each other in ways that make the resulting complexity not worth it.
- ihnorton 6y agoThe principal developer of Pyston commented on the JavaScript comparison recently [1]: > This is a common view but I've never heard it from someone who has tried to optimize Python. Personally I think that Python is as much more dynamic than JavaScript as JavaScript is than C. [1] https://news.ycombinator.com/item?id=23247618 https://news.ycombinator.com/item?id=23247618
- arc776 6y agoThe thing about Javascript is it's actually a very simple language. You can make a lot of guarantees and this means performance patterns can be implied. Ultimately JS can be reduced to a very tight engine. This is not possible with Python, it's just too dynamic.