You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason is that take ensures that the output is unchanged when an out-of-bounds access happens.
That is how it has always been, I don't disagree that this is likely not needed. Not sure about changing it, but I would be OK if a few people are in favor (with a release note).
Let's bring it up at the triage meeting. I am carefully in favor of just changing it with a release note. It just feels like out= is usually for speed, and you can use out[...] = take(arr, idx).
So, if you are interested in this, I think this is likely enough to happen that opening a PR for it is useful.
(Adding a mode seems a lot of addition for nothing to me.)
Activity
[-]`numpy_take` slower when `out` is provided[/-][+]`take` slower when `out` is provided[/+]ngoldbaum commentedon Apr 3, 2025
I see the same thing on my Mac:
Let me see if I can get samply to give me a useful profile so we can understand where the difference is.
ngoldbaum commentedon Apr 3, 2025
The difference is that using
outleads to a code path that does a copy. I'm not sure offhand why a copy is necessary here.with
out:without:
EDIT: (also pretty neat that you can get Python frames in samply profiles!)
seberg commentedon Apr 3, 2025
The reason is that
takeensures that the output is unchanged when an out-of-bounds access happens.That is how it has always been, I don't disagree that this is likely not needed. Not sure about changing it, but I would be OK if a few people are in favor (with a release note).
EDIT: I.e.
mode="wrap"makes this go away.ricardoV94 commentedon Apr 3, 2025
I would like to have it raise still. If anybody objects to changing the behavior could we instead have an additional raise+mutate mode instead?
seberg commentedon Apr 4, 2025
Let's bring it up at the triage meeting. I am carefully in favor of just changing it with a release note. It just feels like
out=is usually for speed, and you can useout[...] = take(arr, idx).So, if you are interested in this, I think this is likely enough to happen that opening a PR for it is useful.
(Adding a
modeseems a lot of addition for nothing to me.)ricardoV94 commentedon Apr 4, 2025
Totally agree
mattip commentedon Aug 20, 2025
We discussed this at a triage meeting and would like to see a PR to implement the idea of avoiding a copy.
Ijtihed commentedon Jul 8, 2026
I can take a look at and implement this. gut feeling says it'll be easy and quite a performance boost. let's see!