Remix.run Logo
wbpaelias 5 hours ago

I wonder how much Julia’s JIT could help inform Python’s.

Diagram: https://docs.julialang.org/en/v1/devdocs/img/compiler_diagra...

Documentation: https://docs.julialang.org/en/v1/devdocs/eval/

From what I understand, Julia doesn’t do any tracing at all, it just compiles each function based on the types it receives. Obviously Python doesn’t have multiple dispatch, but that actually might make compilation easier. Swap out the LLVM step with python's IR and they could probably expect a pretty substantial performance improvement. That said I don’t know anything about compilers, I just use both Python and Julia.

maplant 3 hours ago | parent [-]

This is called a method based JIT, and is generally the more common approach to JIT compilation. Tracing JIT is a deliberate design choice that is quite different from method based JITs

pansa2 2 hours ago | parent | next [-]

IIRC Julia's is a particularly simple method-based JIT for a dynamically-typed language.

I'm not sure exactly how it differs from most JavaScript JITs, but I believe it just compiles each method once for each set of function argument types - for example, it doesn't try to dynamically determine the types of local variables.

wbpaelias an hour ago | parent [-]

I think the compiler figures that if a new method comes up, it’ll just compile that when it needs to.

wbpaelias an hour ago | parent | prev [-]

That makes sense. Why exactly would python need a tracing JIT instead of a method one though? It seems like either could work.