# Optimized Python is as good as Julia

**URL:** <https://discourse.julialang.org/t/optimized-python-is-as-good-as-julia/104432>\
**Category:** Performance\
**Tags:** question\
**Created:** [September 30, 2023, 2:55pm UTC](https://discourse.julialang.org/t/optimized-python-is-as-good-as-julia/104432 "2023-09-30T14:55:29Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Post date:** [October 1, 2023, 10:49am UTC](https://discourse.julialang.org/t/optimized-python-is-as-good-as-julia/104432/21 "2023-10-01T10:49:19Z")

</div>

> [@lmiq](#):
>
> Except that Julia is much more fun 😊

If somebody asks whether it is worth to learn another computer language, then usually practical reasons are not the only ones, and fun factor is an important one. For some fun, see [seven lines of Julia](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416)

As for Python+Numpy vs. Julia for maths. Surely, one gets used to the ubiquitous `np.` suffix, still it is not good for readability. On the Julia side, the acceptance of unicode makes it possible to write concise readable math:

```julia
function i(i₀, ν, ϕ, t)
    ω = π*ν
    return i₀*sin(ω*t + ϕ)
end

```

– you know how the equivalent of it would look in Python.

---

<div class="post-metadata">

**Author:** ![tchebycheff](https://avatars.discourse-cdn.com/v4/letter/t/779978/32.png) [@tchebycheff](https://discourse.julialang.org/u/tchebycheff)\
**Post date:** [October 1, 2023, 11:14am UTC](https://discourse.julialang.org/t/optimized-python-is-as-good-as-julia/104432/22 "2023-10-01T11:14:38Z")

</div>

I find programs with short variable names much more readable than the “industrial convention” long names.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [October 1, 2023, 11:50am UTC](https://discourse.julialang.org/t/optimized-python-is-as-good-as-julia/104432/23 "2023-10-01T11:50:53Z")

</div>

Sure, I totally agree a speed difference like that is not alone a reason to switch programming languages and it’s also not going to be a reliably reproduced number.

I’m just saying it’s not nothing, and I disagree with the original phrasing of the post that says that since julia is **only** 1.5-2x faster than Numpy here, they’re “just as good”.

---

<div class="post-metadata">

**Author:** ![ApeWithAnxiety](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/apewithanxiety/32/202186_2.png) [@ApeWithAnxiety](https://discourse.julialang.org/u/ApeWithAnxiety)\
**Post date:** [October 1, 2023, 7:44pm UTC](https://discourse.julialang.org/t/optimized-python-is-as-good-as-julia/104432/24 "2023-10-01T19:44:54Z")

</div>

You can do this in Python though too, right? I have a program now with a µs for microseconds.

---

<div class="post-metadata">

**Author:** ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Post date:** [October 1, 2023, 8:01pm UTC](https://discourse.julialang.org/t/optimized-python-is-as-good-as-julia/104432/25 "2023-10-01T20:01:55Z")

</div>

yes, indeed, my bad. Though I think not everything - `i₀` appears not possible.

What about the mathematical function names (`np.sin` etc.?)

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [October 3, 2023, 11:42am UTC](https://discourse.julialang.org/t/optimized-python-is-as-good-as-julia/104432/26 "2023-10-03T11:42:18Z")

</div>

At least 7x faster is a good reason to use Julia (in not “_only_ 1.5-2x faster than Numpy”), and likely it can be improved further.

For your “two”- or four-line example, I would actually rather show off the concise one-line possibility of defining a function in Julia:

```julia
i(i₀, ν, ϕ, t) = i₀*sin(π*ν*t + ϕ) # or even for more accuracy and speed: = i₀*sinpi(ν*t + ϕ*(1/π))

```

---

<div class="post-metadata">

**Author:** ![pddshk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pddshk/32/208547_2.png) [@pddshk](https://discourse.julialang.org/u/pddshk)\
**Post date:** [April 17, 2024, 8:35am UTC](https://discourse.julialang.org/t/optimized-python-is-as-good-as-julia/104432/27 "2024-04-17T08:35:01Z")

</div>

> [@dlakelan](#):
>
> `sum(a == b for (a,b) in zip(hats,ideal))`

Or if you take a closer look at `ideal` which is simply `1:n` then it could be

```julia
count(splat(==), enumerate(hats))

```

Eliminating `ideal` at all

---

<div class="post-metadata">

**Author:** ![picoman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/picoman/32/217112_2.png) [@picoman](https://discourse.julialang.org/u/picoman)\
**Post date:** [June 2, 2025, 11:50am UTC](https://discourse.julialang.org/t/optimized-python-is-as-good-as-julia/104432/28 "2025-06-02T11:50:54Z")

</div>

This post was temporarily hidden by the community for possibly being off-topic, unfocused, inappropriate, or spammy.

---

<div class="post-metadata">

**Author:** ![picoman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/picoman/32/217112_2.png) [@picoman](https://discourse.julialang.org/u/picoman)\
**Post date:** [June 2, 2025, 11:55am UTC](https://discourse.julialang.org/t/optimized-python-is-as-good-as-julia/104432/29 "2025-06-02T11:55:55Z")

</div>

This post was temporarily hidden by the community for possibly being off-topic, unfocused, inappropriate, or spammy.

[Previous page](https://discourse.julialang.org/t/optimized-python-is-as-good-as-julia/104432.md?page=1)
