[Pyrex] Pyrex checks type of literal None argument

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Tue May 23 08:42:25 CEST 2006


Hi,

I have a C function defined as

  cdef _RetType factory(sometype* arg1, _SomeType arg2):
      ...

I then call it with a literal None as second argument:

  value = factory(somepointer, None)

Pyrex generates this code for it:

  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5etree__SomeType)) { ... }

  __pyx_2 = ((PyObject *)__pyx_f_5etree_factory(__pyx_v_c_doc,
        ((struct __pyx_obj_5etree__SomeType *)Py_None))); if (!__pyx_2) {...}

I think the type check should be optimised away.

Stefan



More information about the Pyrex mailing list