[Numpy-discussion] New iterator APIs (nditer / MapIter): Overlap detection in NumPy
Pauli Virtanen
pav at iki.fi
Mon Sep 12 16:22:40 EDT 2016
Mon, 12 Sep 2016 11:31:07 +0200, Sebastian Berg kirjoitti:
>> * NPY_ITER_COPY_IF_OVERLAP, NPY_ITER_OVERLAP_NOT_SAME
>> flags for NpyIter_New.
>>
>> * New API function PyArray_MapIterArrayCopyIfOverlap,
>> as ufunc.at needs to check overlaps for index arrays before
>> constructing iterators, and the parsing is done in multiarray.
>
> I think here Nathaniels point might be right. It could be we can assume
> that copying is always fine, there is probably only one or two
> downstream projects using this function, plus it seems harder to create
> abusing structures that actually do something useful.
> It was only exposed for usage in `ufunc.at` if I remember right. I know
> theano uses it though, but not sure about anyone else, maybe numba. On
> the other hand.... It is not the worst API clutter in history.
Do you suggest that I break the PyArray_MapIterArray API?
One issue here is that the function doesn't make distinction between read-
only access and read-write access, so copying may give unnecessary
slowdown. The second thing is that it will result to a bit uglier code, as
I need to manage the overlap with the second operation in ufunc_at.
For NpyIter, I'd still be wary about copying by default, because it's not
needed everywhere (the may_share_memory checks are better done earlier),
and since the semantic change can break things inside Numpy.
Pauli
More information about the NumPy-Discussion
mailing list