[Numpy-svn] r8366 - trunk/numpy/core/src/multiarray

numpy-svn@scip... numpy-svn@scip...
Sun Apr 25 20:02:07 CDT 2010


Author: charris
Date: 2010-04-25 20:02:07 -0500 (Sun, 25 Apr 2010)
New Revision: 8366

Modified:
   trunk/numpy/core/src/multiarray/methods.c
Log:
ENH: Simplify some functions using NpyArg_ParseKeywords.

Modified: trunk/numpy/core/src/multiarray/methods.c
===================================================================
--- trunk/numpy/core/src/multiarray/methods.c	2010-04-26 01:02:04 UTC (rev 8365)
+++ trunk/numpy/core/src/multiarray/methods.c	2010-04-26 01:02:07 UTC (rev 8366)
@@ -100,22 +100,15 @@
 static PyObject *
 array_reshape(PyArrayObject *self, PyObject *args, PyObject *kwds)
 {
+    static char *keywords[] = {"order", NULL};
     PyArray_Dims newshape;
     PyObject *ret;
     PyArray_ORDER order = PyArray_CORDER;
     int n;
 
-    if (kwds != NULL) {
-        PyObject *ref;
-        ref = PyDict_GetItemString(kwds, "order");
-        if (ref == NULL) {
-            PyErr_SetString(PyExc_TypeError,
-                            "invalid keyword argument");
-            return NULL;
-        }
-        if ((PyArray_OrderConverter(ref, &order) == PY_FAIL)) {
-            return NULL;
-        }
+    if (!NpyArg_ParseKeywords(kwds, "|O&", keywords,
+                PyArray_OrderConverter, &order)) {
+        return NULL;
     }
 
     n = PyTuple_Size(args);
@@ -942,13 +935,8 @@
     PyObject *ret, *obj;
 
 
-    if (kwds != NULL) {
-        PyObject *tmp = PyTuple_New(0);
-        if (!PyArg_ParseTupleAndKeywords(tmp, kwds, "|i", kwlist,  &refcheck)) {
-            Py_XDECREF(tmp);
-            return NULL;
-        }
-        Py_DECREF(tmp);
+    if (!NpyArg_ParseKeywords(kwds, "|i", kwlist,  &refcheck)) {
+        return NULL;
     }
 
     if (size == 0) {



More information about the Numpy-svn mailing list