# Julia Beginner (from Python): Numba outperforms Julia in rewrite. Any tips to improve performance?

**URL:** <https://discourse.julialang.org/t/julia-beginner-from-python-numba-outperforms-julia-in-rewrite-any-tips-to-improve-performance/66414>\
**Category:** Performance\
**Tags:** benchmark, python, tullio, loopvectorization\
**Created:** [August 15, 2021, 12:00am UTC](https://discourse.julialang.org/t/julia-beginner-from-python-numba-outperforms-julia-in-rewrite-any-tips-to-improve-performance/66414 "2021-08-15T00:00:50Z")\
**Posts on this page:** 1\
**Showing post:** 24

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [August 16, 2021, 7:28pm UTC](https://discourse.julialang.org/t/julia-beginner-from-python-numba-outperforms-julia-in-rewrite-any-tips-to-improve-performance/66414/24 "2021-08-16T19:28:13Z")

</div>

This is probalby a MWE for the critical loop, in Julia:

```julia
using BenchmarkTools
using LoopVectorization

function get_gains!(x, y, idxs, gains)
    @tturbo for i in eachindex(idxs)
        s = 0.0
        for j in eachindex(y)
            s += sqrt(y[j] + x[j, idxs[i]])
        end
        gains[i] = s
    end
end;

d = 54
n = 581012
x = rand(54, 581012)*100;
y = zeros(Float64, d)
idxs = collect(1:n);
gains = zeros(Float64, n);

@benchmark get_gains!($x, $y, $idxs, $gains)

```

Do you agree this is the bottleneck? But I’m too unfamiliar with Python and Numba to be sure to write something comparable there.

If we can really localize and quantify the performance difference, than we can post an issue, somewhere so someone can take a look at it.

> [@rmeinl](#):
>
> ```julia
> # NaiveGreedy old 
> 11.923 s (82912 allocations: 15.02 MiB)
> 
> ```

ps: what is the Python time for the naive greedy algorithm in this case?

---

_[View the full topic](https://discourse.julialang.org/t/julia-beginner-from-python-numba-outperforms-julia-in-rewrite-any-tips-to-improve-performance/66414)._
