diff options
author | Travis Oliphant <oliphant@enthought.com> | 2005-10-06 22:15:37 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2005-10-06 22:15:37 +0000 |
commit | c2871a8b8b80fc3505195b179baa1472d46e063f (patch) | |
tree | 6417e05c9a6057e24baad38f487b4515899ab188 /scipy/base/src/arrayobject.c | |
parent | 6de1ded3b69fc30f2588ba18daeeaccb8f399c5f (diff) | |
download | numpy-c2871a8b8b80fc3505195b179baa1472d46e063f.tar.gz |
Added optimization for array_subscript and eleminated threaded support for a while.
Diffstat (limited to 'scipy/base/src/arrayobject.c')
-rw-r--r-- | scipy/base/src/arrayobject.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/scipy/base/src/arrayobject.c b/scipy/base/src/arrayobject.c index d839365a7..931bac6a5 100644 --- a/scipy/base/src/arrayobject.c +++ b/scipy/base/src/arrayobject.c @@ -16,7 +16,7 @@ Brigham Young University maintainer email: oliphant.travis@ieee.org -Numarray design by +Numarray design (which provided guidance) by Space Science Telescope Institute (J. Todd Miller, Perry Greenfield, Rick White) @@ -36,7 +36,7 @@ Space Science Telescope Institute #define error_converting(x) (((x) == -1) && PyErr_Occurred()) -static int +static intp PyArray_PyIntAsIntp(PyObject *o) { longlong long_value = -1; @@ -1669,6 +1669,15 @@ array_subscript(PyArrayObject *self, PyObject *op) PyArrayObject *other; PyArrayMapIterObject *mit; + if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \ + PyLong_Check(op)) { + intp value; + value = PyArray_PyIntAsIntp(op); + if (PyErr_Occurred()) + PyErr_Clear(); + else if ((value <= MAX_INT) || (value >= -MAX_INT)) + return array_item(self, (int) value); + } if (PyArrayMapIter_Check(op)) { mit = (PyArrayMapIterObject *)op; |