On Sat, Dec 20, 2025 at 4:21 PM Mark Harfouche via NumPy-Discussion <
[email protected]> wrote:

> The current array_equal implementation allocates an intermediate array for
> the elementwise comparison of the two input arrays.
>
> it would be great to do all this in c that is something like a reduction
> operation.
>
> I say this because certain workflows (zarr) like to check for equality
> against "zero" and simply not encode the data to avoid extra files on disk.
>
> this inevitably means that something like a full memory copy of your array
> is allocated for this equality check, which should only have a memory
> footprint of O(1) instead of O(n) which it has now.
>
> Are PRs welcome to implement optimize this?
>
> https://github.com/numpy/numpy/blob/67fc5c311eea54b27e43c2c769b3b8f878ae43f9/numpy/_core/numeric.py#L2528
>

PRs that make existing functionality faster are always welcome. The main
criterion for acceptance is that extra complexity should be justified by
the performance gains (e.g., adding hundreds of lines of C code to make it
20% faster is not okay, but if it'd be 3x faster than sure why not).


> Selfishly, I would love to optimize the equal_nan=False usecase first, but
> perhaps with AI assistants, we can do both in 1 shot....
>

Note that we expect contributors to own the copyright of their submissions
as well as understand the code they write. So using AI tooling as a search
engine or code completion sure, but you cannot use it to generate new
algorithmic code like this.

Cheers,
Ralf



>
> Let me know your thoughts
>
> Best,
>
> Mark
> _______________________________________________
> NumPy-Discussion mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3//lists/numpy-discussion.python.org
> Member address: [email protected]
>
_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/numpy-discussion.python.org
Member address: [email protected]

Reply via email to