On Tue, Nov 3, 2009 at 12:28 PM, Dag Sverre Seljebotn <[email protected]> wrote: > Stefan Behnel wrote: >> Robert Bradshaw, 03.11.2009 10:22: >> >>> On Oct 25, 2009, at 11:53 AM, Lisandro Dalcin wrote: >>> >>>> I think Cython could generate a custom, inline function >>>> implementing l.pop([n]) and fast dispatch to it if the object is >>>> exactly a list ... >>>> >>> http://hg.cython.org/cython-devel/rev/2e3dda4a7d23 >>> >> >> Hmm, is this really worth the code duplication with CPython? I mean, we are >> partly copying the list-shrink trigger algorithm here, which I would prefer >> to consider an implementation detail of the list type. >> > I second this, this is the kind of code I don't like to see Cython > output. At the very least, one should #IFDEF it to only kick in with > known good Python versions...it's not the kind of thing we'll > automatically remember to check when Python 3.4 comes out. > > It should be possible to find a middle route somewhere though? (At the > very least prefetch "pop" of the list type rather than use getattr every > time.) > > Dag Sverre > _______________________________________________ > Cython-dev mailing list > [email protected] > http://codespeak.net/mailman/listinfo/cython-dev >
I agree with Stefan and Dag... Why not use PyList_GET_ITEM(L) + Py_INCREF() + PyList_SetSlice() ?? This way, you could easily support "L.pop(index)"... -- 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
