Ticket #1308 (closed enhancement: fixed)
Make np.dot and np.inner fast for read-only arrays.
| Reported by: | hansres | Owned by: | somebody |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.0.0 |
| Component: | numpy.core | Version: | |
| Keywords: | Cc: |
Description
Currently np.dot/np.inner are much slower (~3x) for read-only arrays than for writeable arrays.
In [1]: a = randn(1e6) In [2]: %timeit dot(a, a) 100 loops, best of 3: 5.42 ms per loop In [3]: a.setflags(write=False) In [4]: %timeit dot(a, a) 100 loops, best of 3: 15.9 ms per loop.
This slowdown for read-only inputs is caused by the creation of array copies: dot/inner call PyArray_FromAny and require the WRITABLE flag. Instead, because read-only input arrays are fine, the WRITEABLE flag should not be is not required; and the ALIGNED flag should be sufficient.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.
