Closed hyanwong closed 5 months ago
https://github.com/hyanwong/GeneticInheritanceGraphLibrary/tree/numpy-edge-table shows that it can be done. We should probably implement this, but it requires a bit of thought to do it in the simplest way.
Merged in #116
Peter Ralph suggested we could store the iedge data in a numpy array. We can wrap the whole thing in a class which will preallocate memory in the right way. We could use the numpy recarray class (which is a wrapper for structured arrays) but I have read that it can be slower for accessing attributes, because of the checking it has to do. I think we can just use structured arrays with a bit of syntactic sugar, and it should be very fast. Here's an outline: I think it might just be a drop-in replacement. I'm hoping that this could make everything much faster:
Giving:
Note the slight issue at the end that any references to the old arrays will not reflect the original data when a new memory array has been allocated. I guess there's nothing we can do about that, and it's an edge case anyway.