numpy / numpy/numpy

Poor ndarray.take performance on Fortran order arrays (Trac #2065)

Open
#2,657 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

01 - Enhancement component: numpy._core component: numpy.dtype
Dominant language
Python
Stars
32.8k
Forks
12.8k
Avg merge
1d 7h
Merged PRs (30d)
197

Description

Original ticket http://projects.scipy.org/numpy/ticket/2065 on 2012-02-26 by @wesm, assigned to unknown.

3000x slowdown observed:

In [25]: arr = np.random.randn(350000, 5)

In [26]: timeit arr.take(np.arange(5), axis=0)
100000 loops, best of 3: 2.86 us per loop

In [27]: arr = np.random.randn(350000, 5).copy('F')

In [28]: timeit arr.take(np.arange(5), axis=0)
100 loops, best of 3: 9.03 ms per loop

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two timing examples in the issue, comparing ndarray.take for default- and Fortran-order arrays. Read the ndarray.take entry point and trace the Fortran-order path. Done means the reported slowdown is addressed without changing take's behavior, with the benchmark confirming the improvement.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.