diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-07-06 10:50:32 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-07-06 10:50:32 +0000 |
commit | a6d06e1fd07f0d358461661254581e8fe60733d1 (patch) | |
tree | 2b725bd9a439238ef6ec45c2c495694984740c0e /numpy/core/src/arrayobject.c | |
parent | 11aa95a6a4978a687288f62287c147a63f834acb (diff) | |
download | numpy-a6d06e1fd07f0d358461661254581e8fe60733d1.tar.gz |
Add .M .A .T .H to array scalars.
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r-- | numpy/core/src/arrayobject.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 999a43b79..1c2f4c624 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -504,6 +504,23 @@ copy_and_swap(void *dst, void *src, int itemsize, intp numitems, static PyArray_Descr **userdescrs=NULL; #define error_converting(x) (((x) == -1) && PyErr_Occurred()) +static PyTypeObject *matrix_type=NULL; + +static PyTypeObject * +_load_matrix_type(void) +{ + PyObject *mod; + PyTypeObject *ret; + /* Load it from numpy */ + mod = PyImport_ImportModule("numpy"); + if (mod == NULL) return NULL; + ret = (PyTypeObject *) \ + PyObject_GetAttrString(mod, "matrix"); + Py_DECREF(mod); + return ret; +} + + /* Computer-generated arraytype and scalartype code */ #include "scalartypes.inc" #include "arraytypes.inc" @@ -6198,15 +6215,8 @@ array_asarray_get(PyArrayObject *self) static PyObject * array_asmatrix_get(PyArrayObject *self) { - /* Keeps a reference */ - static PyTypeObject *matrix_type = NULL; if (matrix_type == NULL) { - PyObject *mod; - /* Load it from numpy */ - mod = PyImport_ImportModule("numpy"); - if (mod == NULL) return NULL; - matrix_type = (PyTypeObject *) \ - PyObject_GetAttrString(mod, "matrix"); + matrix_type = _load_matrix_type(); if (matrix_type == NULL) return NULL; } if (self->nd > 2) { |