6 ms·
Let'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 th
by junon 4y ago
Let'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".