On Sat, Sep 24, 2011 at 10:26 AM, leif <not.rea...@online.de> wrote: > On 24 Sep., 18:25, "D. S. McNeil" <dsm...@gmail.com> wrote: >> Leif wrote: >> > Any reasonable compiler does constant folding and loop-invariant code >> > motion; even Python's byte-code compiler should do that. >> >> Almost none is done. Only the most trivial cases are handled. [...] > > OMG. That's why I said "reasonable" and "should"... ;-)
The bytecode compiler is not an optimizing compiler. >> I guess discussion should take place on the ticket, but, just for the >> record: It might be worth while to use an annotated version of the >> cython code (the notebook provides it); one finds that most lines of >> code have a big overhead over C. > > Yes, I am aware of that; but in this case it was nearly all yellow :) > which is why I didn't want to just add cdef's all over the place willy- > nilly. Well, it would still help generate comments. For the record, http://sage.math.washington.edu/home/robertwb/tmp/newton_basins_with_iterations_and_double.html Some general comments: 1) newtf is a fast callable first (and perhaps using the cdef version of call on it). When you do f1 = Finder.which_root # creates an *object* f1 f1(...) you're not taking advantage of the fact that which_root is a cpdef function. This is probably where the bulk of your time is going. 2) In your inner loop, you could write cdef double rdiff, idiff rdiff = root._complex[0] - varia._comlex[0] idfff = root._complex[1] - varia._comlex[1] if (rdiff**2 + idiff**2) < tol: ... to save on object creation here. You could even make roots into a double complex *, though I bet the bulk of your time is being spent in (1). It could be possible to do everything in terms of double complex, rather than CDF elements, which might be a big win. - Robert -- 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