4 ms·
That’s something that has always puzzled me as well. Given the popularity, you’d think Python would have had several generations of JITs by now and yet it stil
by tambourine_man 4y ago
That’s something that has always puzzled me as well.
Given the popularity, you’d think Python would have had several generations of JITs by now and yet it still runs interpreted, AFAIK.
JavaScript has proven that any language can be made fast given enough money and brains, no matter how dynamic.
Maybe Python's C escape hatch is so good that it’s not worth the trouble. It’s still puzzling to me though.
- dragonwriter 4y ago> JavaScript has proven that any language can be made fast given enough money and brains, Yeah but commercial Smalltalk proved that a long time before JS did. (Heck, back when it was maintained, the fastest Ruby implementation was built on top of a commercial Smalltalk system, which makes sense given they have a reasonably similar model.) The hard part is that “enough money“ is...not a given, especially for noncommercial projects. JS got it because Google decided JavaScript speed was integral to it's business of getting the web to replace local apps. Microsoft recently developed sufficient interest in Python to throw some money at it.
- tambourine_man 4y agoYes, I’m aware of the Smalltalk miracle. Google wasn’t alone in optimizing JS, it actually came late, Safari and Firefox were already competing and improving their runtime speeds, though V8 did doubled down on the bet of a fast JS machine. The question is why there isn’t enough money, given that there obviously is a lot of interest from big players.
- dragonwriter 4y ago> The question is why there isn’t enough money, given that there obviously is a lot of interest from big players. I'd argue that there wasn't actually much interest until recently, and that's because it is only recently that interest in the CPython ecosystem has intersected with interest in speed that has money behind it, because of the sudden broad relevance to commercial business of the Python scientific stack for data science. Both Unladen Swallow and IronPython were driven by interest in Python as a scripting language in contexts detached from, or at least not necessarily attached to, the existing CPython ecosystem.
- tambourine_man 4y agoProbably. I’m not a heavy Python user. A better question would be to ask where Python is slow today and if it matters to big business, then. It rules in AI, for instance. Is it still mainly glue code for GPU execution and performance isn’t at all critical there?
- 323 4y agoJavaScript doesn't really have C extensions like Python has. PyPy did implement a JIT for Python, and it worked really well, until you tried to use C extensions.
- tambourine_man 4y agoThat’s what I meant, if JavaScript hadn’t been trapped in the browser and allowed to call C, maybe there wouldn’t have been so much investment in making it fast. But still, it’s kind of surprising that PHP has a JIT and Python doesn’t (official implementation I mean, not PyPy).
- int_19h 4y agoPython has a lot more third-party packages that are written in native code. PHP has few partly because it just isn't used much outside of web dev, and partly because the native bits that might be needed for web devs, like database libraries, are included in the core distro.
- pjmlp 4y agoBecause it has to, there is no other way to make it fast, as typical two language dilemma.
- everforward 4y ago> Maybe Python's C escape hatch is so good that it’s not worth the trouble. Even if it wasn't good, the presence of it reduces the necessity of optimizing the runtime. You couldn't call C code in the browser at all until WASM; the only way to make JS faster was to improve the runtime. > JavaScript has proven that any language can be made fast given enough money and brains, no matter how dynamic. JavaScript also lacks parallelism. Python has to contend with how dynamic the language is, as well as that dynamism happening in another thread. There are some Python variants that have a JIT, though they aren't 100% compatible. Pypy has a JIT, and iirc, IronPython and JPython use the JIT from their runtimes (.Net and Java, respectively).