Ticket #12029: list_speedup.patch

File list_speedup.patch, 1.2 KB (added by hivert, 19 months ago)
  • sage/structure/list_clone.pyx

    # HG changeset patch
    # User Florent Hivert <Florent.Hivert@univ-rouen.fr>
    # Date 1321345415 -3600
    # Node ID f901d81985378a3dd36776bfac1feb8640e12691
    # Parent  70ef7738ff73d6eb8e6df1693f5f808b1ce25868
    [mq]: list_speedup.patch
    
    diff --git a/sage/structure/list_clone.pyx b/sage/structure/list_clone.pyx
    a b AUTHORS: 
    130130 
    131131 
    132132include "../ext/stdsage.pxi" 
     133include "../ext/python_list.pxi" 
     134include "../ext/python_int.pxi" 
     135include "../ext/python_ref.pxi" 
    133136 
    134137import sage 
    135138from sage.structure.element cimport Element 
    cdef class ClonableIntArray(ClonableElem 
    14491452            False 
    14501453            sage: I.list() == range(5) 
    14511454            True 
    1452  
     1455            sage: I = IncreasingIntArrays()(range(1000)) 
     1456            sage: I.list() == range(1000) 
     1457            True 
    14531458        """ 
    14541459        cdef int i 
    1455         cdef list L = [] 
     1460        cdef list L = <list> PyList_New(self._len) 
     1461        cdef object o 
    14561462        for  i from 0<=i<self._len: 
    1457             L.append(self._list[i]) 
     1463            o = PyInt_FromLong(self._list[i]) 
     1464            Py_INCREF(o) 
     1465            PyList_SET_ITEM(L, i, o) 
    14581466        return L 
    14591467 
    14601468    def __getitem__(self, key):