# Question on simple performance comparison between Python and Julia

**URL:** <https://discourse.julialang.org/t/question-on-simple-performance-comparison-between-python-and-julia/100225>\
**Category:** General Usage\
**Tags:** question\
**Created:** [June 12, 2023, 10:54am UTC](https://discourse.julialang.org/t/question-on-simple-performance-comparison-between-python-and-julia/100225 "2023-06-12T10:54:53Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![johnmyleswhite](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnmyleswhite/32/31_2.png) [@johnmyleswhite](https://discourse.julialang.org/u/johnmyleswhite)\
**Post date:** [June 12, 2023, 10:22pm UTC](https://discourse.julialang.org/t/question-on-simple-performance-comparison-between-python-and-julia/100225/21 "2023-06-12T22:22:10Z")

</div>

> [@gdalle](#):
>
> - For complex functions that are called 1 time, compilation time is negligible compared to runtime
> - For small components that are called N times, compilation time is negligible compared to N x runtime

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:

```julia
total_runtime = time_to_compile + N * single_execution_runtime

```

In Python, it’s

```julia
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.

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [June 12, 2023, 10:52pm UTC](https://discourse.julialang.org/t/question-on-simple-performance-comparison-between-python-and-julia/100225/22 "2023-06-12T22:52:36Z")

</div>

I like to include process startup time too which is about

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

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [June 13, 2023, 5:34am UTC](https://discourse.julialang.org/t/question-on-simple-performance-comparison-between-python-and-julia/100225/23 "2023-06-13T05:34:00Z")

</div>

> [@jar1](#):
>
> I like to include process startup time too

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.

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [June 13, 2023, 8:38am UTC](https://discourse.julialang.org/t/question-on-simple-performance-comparison-between-python-and-julia/100225/24 "2023-06-13T08:38:12Z")

</div>

Thanks! Very reasonable. 🤔

[Previous page](https://discourse.julialang.org/t/question-on-simple-performance-comparison-between-python-and-julia/100225.md?page=1)
