On Apr 21, 2:35 am, sturlamolden <[EMAIL PROTECTED]> wrote:

> This also shows how easy it is to boost the performance of Python code
> using Cython.

We can improve this further by getting rid of the tmp.append attribue
lookup:

cdef _flatten(lst, append):
    for elem in lst:
        if type(elem) != list:
            append(elem)
        else:
            _flatten(elem, append)

def flatten(lst):
    tmp = []
    _flatten(lst, tmp.append)
    return tmp

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to