[Numpy-discussion] neighborhood iterator speed
Mon Oct 24 06:56:42 CDT 2011
On Mon, Oct 24, 2011 at 10:48 AM, Nadav Horesh <firstname.lastname@example.org> wrote:
> * Iterator mode: Mirror. Does the mode make a huge difference?
It could, at least in principle. The underlying translate function is
called often enough that a slight different can be significant.
> * I can not find any reference to PyArrayNeightborhoodIter_Next2d, where can I find it?
I think it would look like:
static NPY_INLINE int
iter->dataptr = iter->translate((PyArrayIterObject*)iter,
The ...IncrCoord2 macro avoid one loop, which may be useful (or not).
The big issue here is the translate method call that cannot be inlined
because of the "polymorphism" of neighborhood iterator. But the only
way to avoid this would be to have many different iterators so that
the underlying translate function is known.
Copying the data makes the call to translate unnecessary (but adds the
penalty of one more conditional on every PyArrayNeighborhood_Next.
> * I think that making a copy on reset is (maybe in addition to the creation), since there is a reset for every change of the parent iterator, and after this change, the neighborhood can be determined.
you're right of course, I forgot about the parent iterator.
> * What do you think about the following idea?
> * A neighbourhood iterator generator that accepts also a buffer to copy in the neighbourhood.
> * A reset function that would refill the buffer after each parent iterator modification
The issue with giving the buffer is that one needs to be carefull
about the size and all. What's your usecase to pass the buffer ?
More information about the NumPy-Discussion