-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
numpy scalar * array-like == performance horror #3375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If you define an Your object is a python sequence it is not something that indicates it knows about arrays to numpy. Numpy can convert it, but it cannot do any assumptions about it. It should be sufficient to define |
|
Actually, I spoke too soon. This here:
prints
so the (Forgot to say: I'd like to request that this bug be reopened.) |
True, probably the check for array priority needs to be moved further to the front somewhere, this is not good. I guess the thing gets converted to an array, and only then it notices that the actual object knew what to do in the first place. |
When I run this:
I get this:
Is there a way to tell
numpy
, "no, don't worry about it, just call__rmul__
on the whole thing, instead of picking it apart?"In my specific case,
MyThing
is an array-like object that lives on a GPU, and while it's possible (and not necessarily incorrect) to pick the array apart in this way, it's unexpected and has really terrible performance.(sorry about the many edits)
The text was updated successfully, but these errors were encountered: