performance issue with F-order array
See original GitHub issueReporting a bug
- I have tried using the latest released version of Numba (most recent is visible in the change log (https://github.com/numba/numba/blob/main/CHANGE_LOG).
- I have included a self contained code sample to reproduce the problem. i.e. it’s possible to run as ‘python bug.py’.
run once before the test to make sure it’s compiled:
@njit
def foo(a, b):
return a * b
a = np.random.randn(8192, 2592)
b = np.copy(a)
%%timeit -n 10
_ = foo(a, b)
# 83.7 ms ± 1.67 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
%%timeit -n 10
_ = foo.py_func(a, b)
# 29.6 ms ± 558 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
af, bf = map(np.asfortranarray, (a, b))
%%time
_ = foo(af, bf)
# CPU times: user 1.75 s, sys: 54.6 ms, total: 1.8 s
# Wall time: 1.74 s
%%timeit -n 10
_ = foo.py_func(af, bf)
# 30.8 ms ± 420 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
We can observe a significant slow down with F-order array compared to pure numpy codes. BTW, even original C-order version is slower too.
Issue Analytics
- State:
- Created 10 months ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Is there a performance impact when calling ToList()?
When calling on an array, list, or other collection, you create a copy of the collection as a List<T> . The performance here...
Read more >Looking for performance? Probably you should NOT use [].sort ...
You can test speed by sorting bigger and bigger array, stop, if suma of times bigger than limit. In my code is quick...
Read more >Find and sort has poor performance · Issue #645 - GitHub
Each operation by itself is very fast. I can run a simplesort() or find() the whole collection in 1ms each, but if I...
Read more >How to speed up Array's Sorting in Swift - Eltima
But if the files are sorted like in the Finder, performance drops dramatically in case array contains a big amount of elements.
Read more >10 Most Common Mistakes That PHP Developers Make - Toptal
Common Mistake #1: Leaving dangling array references after foreach loops ... The problem is that, if you're not careful, this can also have...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I tested with 0.56.3. I’ve not tested with older versions.
Once the PR is merged, either F or C will be fine, but mixed will always be slower.