On Mon, Oct 24, 2011 at 10:48 AM, Nadav Horesh <nad...@visionsense.com> 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
PyArrayNeighborhoodIter_Next2d(PyArrayNeighborhoodIterObject* iter)
{
    _PyArrayNeighborhoodIter_IncrCoord2d(iter);
    iter->dataptr = iter->translate((PyArrayIterObject*)iter,
iter->coordinates);

    return 0;
}

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 ?

David
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to