Latests Robert's commit optimizing 'isinstance' call breaked the call
to cdef methods. The one line patch below seems to fix the problem,
but anyway this need to be reviewed more carefully. Perhaps an
unimportant gotcha:  the generated code for, let say
'insinstance(None, list)' has two superfluous casts:

  /* "/tmp/qq.pyx":1
 * isinstance(None, list)             # <<<<<<<<<<<<<<
 */
  __pyx_1 = PyObject_TypeCheck(Py_None, ((PyTypeObject
*)((PyObject*)&PyList_Type)));



diff -r 30b7a6c2c7c1 Cython/Compiler/Optimize.py
--- a/Cython/Compiler/Optimize.py       Mon Sep 22 23:45:08 2008 -0700
+++ b/Cython/Compiler/Optimize.py       Tue Sep 23 13:09:36 2008 -0300
@@ -163,7 +163,7 @@ class FinalOptimizePhase(Visitor.CythonT
     def visit_SimpleCallNode(self, node):
         self.visitchildren(node)
         if node.function.type.is_cfunction:
-            if node.function.name == 'isinstance':
+            if getattr(node.function, 'name', None) == 'isinstance':
                 type_arg = node.args[1]
                 if type_arg.type.is_builtin_type and
type_arg.type.name == 'type':
                     object_module = self.context.find_module('python_object')

-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to