On Nov 14, 1:51 pm, William Stein <wst...@gmail.com> wrote: > Hi, > > This thread is about sum. > > 1. Dima said: > > > I don't think sum() method is needed. It's certainly a code bloat. > > This is a very, very misinformed comment. I want to address it, > especially the statement "It's certainly a code bloat."
Sorry if I sounded too categorical on this. I suppose I meant two things: 1) self.sum() on vectors is not too useful. A fast scalar product would be much more useful than .sum(). 2) wanting a fast sum (or a scalar product), that works faster than Python's function sum(), yet does not require a handwritten code in every vector*.pyx, one seems to be hitting the limitation of Cython, which lacks generics. The code from TimeSeries: cpdef double sum(self): ... cdef double s = 0 cdef Py_ssize_t i for i from 0 <= i < self._length: s += self._values[i] return s is totally generic, except the type declaration. If Cython had generics (aka templates) one would have written cpdef T sum(self): ... cdef T s = 0 cdef Py_ssize_t i for i from 0 <= i < self._length: s += self._values[i] return s in the parent class of a vector class over T, rather than in the vector classes, for T=double, etc etc themselves. (Perhaps something like this can still be accomplished within Sage, but I don't see how.) Dima -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org