[Numpy-discussion] Ready for review: PyArrayNeighIterObject, an iterator to iterate over a neighborhood in arbitrary arrays
Sun Jun 14 03:07:03 CDT 2009
On Sun, Jun 14, 2009 at 4:59 PM, David Cournapeau<email@example.com> wrote:
> On Sun, Jun 14, 2009 at 3:51 AM, Charles R
> Harris<firstname.lastname@example.org> wrote:
>> On Sat, Jun 13, 2009 at 12:35 PM, David Cournapeau <email@example.com>
>>> On Sun, Jun 14, 2009 at 3:22 AM, Charles R
>>> Harris<firstname.lastname@example.org> wrote:
>>> > 1) Since reference counting is such a pain, you should document that the
>>> > constructor returns a new reference and that the PyArrayIterObject does
>>> > not
>>> > need to have its reference count incremented before the call and that
>>> > the
>>> > reference count is unchanged on failure.
>>> > 2) Why are _update_coord_iter(c) and _inc_set_ptr(c) macros? Why are
>>> > they
>>> > defined inside functions? If left as macros, they should be in CAPS, but
>>> > why
>>> > not just write them out?
>>> They are macro because they are reused in the 2d specialized functions
>>> (I will add 3d too)
>> IIRC, inline doesn't recurse, so there is some advantage to having these as
>> macros. But I really dislike seeing macros defined inside of functions,
>> especially when they aren't exclusive to that function.
> Well, they are kind of exclusive to this function - and the special 2d
> case; they are not supposed to be used by themselves (which is why
> they are undefined right away). But I changed this anyway to ALL CAPS
> and defined outside.
>> IOW, use macros judiciously.
> It may not be obvious, because it looks really simple, but the code is
> heavily optimized. I spent several hours to find an implementation
> which works as it does now. The macro is used for a reason :)
Forgot a link to the updated version:
More information about the Numpy-discussion