pyuvdata icon indicating copy to clipboard operation
pyuvdata copied to clipboard

speed up _key2inds

Open adampbeardsley opened this issue 8 years ago • 4 comments

Right now the limiting factor in accessing the data quickly is looking up the indices corresponding to a given key. This would be substantially reduced if we can store the key -> index mapping, rather than computing it every time it's needing.

adampbeardsley avatar Jul 04 '17 01:07 adampbeardsley

Should be cached as it is called, not on read.

Also might be faster to assign everything once rather than searching through the baseline array for each key.

bhazelton avatar Apr 29 '20 15:04 bhazelton

We might be able to use functools.lru_cache to generate a cache of key to ind values. then we can have a function that just clears the cache of keys whenever the state of the object changes (add, read, select, etc)

mkolopanis avatar May 19 '20 19:05 mkolopanis

the cache I mentioned before will not work for us because the UVData object itself is unhashable.

mkolopanis avatar May 26 '20 18:05 mkolopanis

I have tried this successfully on a branch, but it would just add another dependency. https://pypi.org/project/memoization/

mkolopanis avatar May 26 '20 18:05 mkolopanis