summaryrefslogtreecommitdiff
path: root/numpy/testing/numpytest.py
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2014-04-09 19:25:27 +0200
committerJulian Taylor <jtaylor.debian@googlemail.com>2014-05-04 22:34:33 +0200
commite47a50efc284c677ba4d0337e11dc8514fca7e5b (patch)
tree21636d9c55b652a652e1c901788de3cf6719975e /numpy/testing/numpytest.py
parent753149eddd46c1c1823fe3932831b2b914bc8724 (diff)
downloadnumpy-e47a50efc284c677ba4d0337e11dc8514fca7e5b.tar.gz
ENH: add small memory chunk cache
Add very simplistic caching of small memory blocks (< 1024 bytes) This improves the performance of small array operations by about 15%-20%: without cache: In [1]: d = np.array([1,1]) In [2]: %timeit d*d*d*d 1000000 loops, best of 3: 2.1 µs per loop with cache: In [1]: d = np.array([1,1]) In [2]: %timeit d*d*d*d 1000000 loops, best of 3: 1.7 µs per loop The cache is a simple list of buckets of pointers, one for each size up to 1023 bytes. Two caches are required one for array data one one for dimensinos/strides as they use different allocators. All pointers can still be deleted with their matching deallocator but this implies the size of the block must be known at the time of the free in order to place the pointer in the right bucket. This should not be an issue for well behaved numpy users. Technically the ABI is broken in this change as the size of the dimension memory block has been decreased from 3 * nd to 2 * nd, the increase to 3 was a relic from the NA branch and is not needed anymore. It should be unlikely someone relies on this size.
Diffstat (limited to 'numpy/testing/numpytest.py')
0 files changed, 0 insertions, 0 deletions