Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork11.9k
Fix "numpy scalar * array-like == performance horror"#3501
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -209,6 +209,26 @@ PyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) | ||
| Py_INCREF(Py_NotImplemented); | ||
| return Py_NotImplemented; | ||
| } | ||
| if (!PyArray_Check(m2)) { | ||
| /* | ||
| * Catch priority inversion and punt, but only if it's guaranteed | ||
| * that we were called through m1 and the other guy is not an array | ||
| * at all. Note that some arrays need to pass through here even | ||
| * with priorities inverted, for example: float(17) * np.matrix(...) | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Nope, that's correct. | ||
| * | ||
| * See also: | ||
| * - https://github.com/numpy/numpy/issues/3502 | ||
| * - https://github.com/numpy/numpy/issues/3503 | ||
| */ | ||
| double m1_prio = PyArray_GetPriority(m1, NPY_SCALAR_PRIORITY); | ||
| double m2_prio = PyArray_GetPriority(m2, NPY_SCALAR_PRIORITY); | ||
| if (m1_prio < m2_prio) { | ||
| Py_INCREF(Py_NotImplemented); | ||
| return Py_NotImplemented; | ||
| } | ||
| } | ||
| return PyObject_CallFunction(op, "OO", m1, m2); | ||
| } | ||