Question on simple performance comparison between Python and Julia

I think it’s likely helpful to OP to make clear that the smallest N for which this applies depends on the runtime cost of the function itself.

In general, a decent model of the Julia total runtime for N executions of a function is:

total_runtime = time_to_compile + N * single_execution_runtime

In Python, it’s

total_runtime = N * single_execution_runtime

That initial fixed cost may or may not be a big deal – it depends on both N and the difference in single execution runtimes. Julia’s single execution runtime can be a lot better, but that may not be enough. For scientific computing, it often is because code is iterative and calls hot functions many times.


I like to include process startup time too which is about

  • Python 3.10: 22 ms
  • Julia 1.9: 220 ms

But that doesn’t apply for each function in a session. It’s relevant if you do all your calls from a command line, but not otherwise.

Every function must be compiled once, but not every function must spin up a new process.

Thanks! Very reasonable. :thinking: