5 ms·
Can anyone that understands these things (i.e. not me, a meek python end user) explain this in simpler terms? I checked th Pyston website, it essentially says
by martopix 4y ago
Can anyone that understands these things (i.e. not me, a meek python end user) explain this in simpler terms?
I checked th Pyston website, it essentially says it makes your code faster and nothing about what's the catch and how it magically works.
- dgacmu 4y agoA JIT is a just-in-time compiler. As your python code is running, the jit looks for opportunities to take little parts of that python code and compile them into executable machine code. Those then run much faster because they don't have to be interpreted instruction by instruction by the python runtime. Not all of the code gets transformed this way so the speedup is modest.
- nine_k 4y agoPyston is JIT compiler, which translates frequently executed bytecode into native code. JIT compilers are what makes Java and JavaScript fast. Pyston's case is closer to JavaScript, I suppose. Since profiling and translation take time, it benefits mostly long-running code, especially servers, and is less useful for transient utilities.
- cwmma 4y agoCompiling takes time, so there is a built in tradeoff to doing a JIT compilation, if you compile the wrong thing the code slows down. In JavaScript at least code needs to be monomorphic to be compiled so if something is almost always called with one type, but occasionally another you can get a massive slowdown (at least in the past I'm assuming this is still the case). More generally all the profiling and whatnot is much more complicated and so everything that entails.
- smcl 4y agoI think the pros/cons of JIT compilation are pretty well known by now, and there's enough expertise floating around that they'd probably be able to implement it in a way that doesn't compromise performance. If I recall one of reasons it wasn't pursued in CPython was that Guido wanted it to be kept relatively simple, and JIT compilation might require some fairly complex additions to CPython which is otherwise relatively simple and easy-to-understand
- klyrs 4y agoMy hope is that the Python team can keep it snappy by default so we don't end up with another Julia. And don't get me wrong, Julia is cool, but the primary drawback is its warmup time. And besides the adoption momentum that Python has, this is the main differentiator in my mind. But Julia's warmup time should serve as a warning: the expertise you claim exists has not saved major projects from the drawbacks of JIT.
- coldtea 4y agoJulia's JIT is not typical. It compiles everything, not doing it piecemeal and smartly with different "execution" layers (like, say v8). It's also based on LLVM, which historically has been slow and crap for JIT work. There are Jitted languages that run circles on top of Python on running time and even startup time.
- coldtea 4y ago>In JavaScript at least code needs to be monomorphic to be compiled so if something is almost always called with one type, but occasionally another you can get a massive slowdown (at least in the past I'm assuming this is still the case). Iirc, V8 has several layers of smarts to deal with this.
- coldtea 4y agoIt compiles your program piecemeal as it runs. The compiled parts don't need to run line by line through the interpreter loop anymore: they're already in memory in cpu-executable form. And (don't know if it does) could even create dedicated faster code for parts of your code, if it can guess the types it works with.
- junon 4y agoLet's assume you speak English - and more importantly, not Chinese. Now, you need to have a conversation with someone who only speaks Chinese. How do you do that? Well, you use an interpreter. They listen to what you say, and translate it to Chinese and speak on your behalf. If you never had any interest in learning Chinese, this would be sufficient. Your conversation rate would be slow but it would get the job done. Let's say there's an intense line of yes-or-no questioning, though. You need to say "yes" or "no" often, and decide that maybe learning the equivalent Chinese words or phrases would cut out the middleman, thus speeding up conversation in some cases. This is what a JIT does, just replace English with Python's bytecode, and Chinese with your host CPU's architecture (e.g. x86 or ARM). The "when" of JITing code varies across implementations and approaches but the concept remains the same. Oftentimes the JIT runtime will translate just the hot codepaths. If a compiler - e.g. one that compiles C code - is "ahead of time", then a runtime that compiles on the fly does so "just in time".