We have a number of algorithms implemented as for loops in python (e.g. the star selectors) that could potentially be done as vectorized numpy expressions. These loops are potentially quite slow, but are necessary because afw tables are not guaranteed to be contiguous in memory, and thus we can’t do the usual (table['value'] == 0) & (table['value2'] > 5)
. We’re likely to run into some significant performance problems once we start running code like this on large catalogs.
The design of afw tables makes it hard to deal with them at the python level, but always doing deep copies to ensure contiguity has its own performance and memory problems.
One possible solution: a “@needs_contiguity” decorator that checks all the arguments of a function and makes deep copies if necessary to make them contiguous. This doesn’t help if the function needs to update values in-place, but could work well otherwise.
Another possibility would be the ability to use the numpy nditer iterator with afw.tables. The syntax would not be as clean as “proper” vectorized numpy statements, but it should be nearly as fast.
Other suggestions or ideas?