[Numpy-discussion] Re: A better syntax for using ufunc.at?

2024-07-25 Thread Dom Grigonis
It would be nicer, yes.

However, at least from my experience, it does not seem to be used often enough 
to go extra mile for the sake of convenience alone.

Regards,
dg

> On 24 Jul 2024, at 13:49, Oras P.  wrote:
> 
> I am aware that to do unbuffered addition operation, I can use `np.add.at` 
> like this:
> ```
> np.add.at(arr, idxs, vals)
> ```
> I think this syntax looks a bit unnatural, and it is not obvious what it does 
> at first glance. An idea I have is to use a custom accessor, like
> ```
> arr.at[idxs] += vals
> # or 
> arr.unbuffered[idxs] += vals
> ```
> While I'm not fluent in Numpy's working mechanisms, this seems possible to 
> implement by just having the method `.at`/`.unbuffered` return a reference to 
> the original array with a special flag set, then make the `+=` operator, etc 
> check this flag and use the unbuffered operation accordingly. 
> 
> Has this kind of feature been proposed at all? I did try to search Github and 
> this mailing list for something similar, but I'm quite new to numpy 
> development, so apologies in advance if this is not the right place to ask.
> ___
> NumPy-Discussion mailing list -- numpy-discussion@python.org
> To unsubscribe send an email to numpy-discussion-le...@python.org
> https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
> Member address: dom.grigo...@gmail.com

___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: A better syntax for using ufunc.at?

2024-07-25 Thread Oras P.
This is interesting, thank you for pointing it out! Good to know this is not a 
Numpy-only problem, I guess lol. Though the proposed syntax looks similar to my 
idea, I believe they are talking about a different problem there relating to 
translating python code to an accelerated language. I simply want a 
`ndarray.at` to be a syntax sugar for accessing `ufunc.at` in a more readable 
way. But if that proposal goes through `at` probably won't be a good name 
anymore, haha.
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: A better syntax for using ufunc.at?

2024-07-25 Thread Oras P.
I can see that. I wanted to be more caught up with the discussions around this 
than anything else.
Although I also have a lot of free time right now temporarily, and could make 
an attempt at implementing it. Is there any other channel I can get more 
feedback on this?
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com