Hi,
http://trac.cython.org/cython_trac/ticket/447 describes an added
optimization for calls to list.pop(). Somewhat counter-intuitively this
optimization is only applied if pop() is called on things of type
"object", not if it is called on things explicitly typed as "list".
Compare the following (silly) examples:
def f():
cdef list l = []
l.append(0)
l.pop()
return l
def f():
cdef object l = []
l.append(0)
l.pop()
return l
Using either Cython 0.12.1 or cython-devel the second one generates
calls to __Pyx_Object_Append and __Pyx_Object_Pop, which take fast paths
if called on a list. The first one generates a direct to PyList_Append,
but then PyObject_GetAttr and PyObject_Call for pop().
It might be nice to add:
_handle_simple_method_list_pop = _handle_simple_method_object_pop
somewhere in Cython/Compiler/Optimize.py, which at least makes Cython
not generate worse code for the more restrictively typed list (tested it
briefly, the resulting code looked reasonable and compiled).
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev