implement _index_data parts of #24024
Besides narrowing down the scope of #24024, I _think_ this might fix the segfaults I had in my old DTA branch, which may make it feasible to hugely simplify the composition changeover.

Aside from removing apparently-unused imports in reduction.pyx, the affected code is copied verbatim from #24024.