summaryrefslogtreecommitdiff
path: root/scipy/base/src/arrayobject.c
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2005-10-06 22:15:37 +0000
committerTravis Oliphant <oliphant@enthought.com>2005-10-06 22:15:37 +0000
commitc2871a8b8b80fc3505195b179baa1472d46e063f (patch)
tree6417e05c9a6057e24baad38f487b4515899ab188 /scipy/base/src/arrayobject.c
parent6de1ded3b69fc30f2588ba18daeeaccb8f399c5f (diff)
downloadnumpy-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.c13
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;