Use shared module for more Cython types.
authorRobert Bradshaw <robertwb@gmail.com>
Tue, 13 Aug 2013 05:37:17 +0000 (22:37 -0700)
committerRobert Bradshaw <robertwb@gmail.com>
Tue, 13 Aug 2013 05:37:17 +0000 (22:37 -0700)
Cython/Utility/CommonTypes.c
Cython/Utility/CythonFunction.c
Cython/Utility/Generator.c

index af10d39..6c1ee74 100644 (file)
@@ -10,7 +10,7 @@ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
     PyObject* sys_modules = NULL;
     PyObject* args = NULL;
     PyTypeObject* cached_type = NULL;
-    char* cython_module = "_cython_" CYTHON_ABI;
+    const char* cython_module = "_cython_" CYTHON_ABI;
     if (fake_module == NULL) {
         sys = PyImport_ImportModule("sys"); if (sys == NULL) goto bad;
         sys_modules = PyObject_GetAttrString(sys, "modules"); if (sys_modules == NULL) goto bad;
index 683999d..0b6d975 100644 (file)
@@ -646,15 +646,10 @@ static int __Pyx_CyFunction_init(void) {
     // avoid a useless level of call indirection
     __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
 #endif
-#if 1
     __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
-    if (__pyx_CyFunctionType == NULL)
+    if (__pyx_CyFunctionType == NULL) {
         return -1;
-#else
-    if (PyType_Ready(&__pyx_CyFunctionType_type) < 0)
-        return -1;
-    __pyx_CyFunctionType = &__pyx_CyFunctionType_type;
-#endif
+    }
     return 0;
 }
 
@@ -1095,10 +1090,10 @@ static PyTypeObject __pyx_FusedFunctionType_type = {
 };
 
 static int __pyx_FusedFunction_init(void) {
-    if (PyType_Ready(&__pyx_FusedFunctionType_type) < 0) {
+    __pyx_FusedFunctionType = __Pyx_FetchCommonType(&__pyx_FusedFunctionType_type);
+    if (__pyx_FusedFunctionType == NULL) {
         return -1;
     }
-    __pyx_FusedFunctionType = &__pyx_FusedFunctionType_type;
     return 0;
 }
 
index 475e8c3..62539d8 100644 (file)
@@ -57,6 +57,7 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue);
 //@requires: Exceptions.c::SwapException
 //@requires: Exceptions.c::RaiseException
 //@requires: ObjectHandling.c::PyObjectCallMethod
+//@requires: CommonTypes.c::FetchCommonType
 
 static PyObject *__Pyx_Generator_Next(PyObject *self);
 static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value);
@@ -653,9 +654,10 @@ static int __pyx_Generator_init(void) {
     /* on Windows, C-API functions can't be used in slots statically */
     __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr;
     __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
-    if (PyType_Ready(&__pyx_GeneratorType_type)) {
+
+    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
+    if (__pyx_GeneratorType == NULL) {
         return -1;
     }
-    __pyx_GeneratorType = &__pyx_GeneratorType_type;
     return 0;
 }