On Fri, Jan 28, 2011 at 9:14 PM, Stefan Behnel <stefan...@behnel.de> wrote: > Robert Bradshaw, 28.01.2011 22:49: >> On Fri, Jan 28, 2011 at 1:01 PM, Stefan Behnel wrote: >>> And given that Cython cannot know that the pointer is actually not a >>> pointer, it generates the expected code here which only the C compiler can >>> detect as invalid. >>> This needs fixing in Sage in one way or another. >> >> Cython didn't used to support tyepdef'd arrays, so that's why it was >> declared as a pointer, but yes, that should be fixed. I'll do that in >> our copy, and it will go out with the 0.14.1 fixes (even though we >> don't need it yet). There's still the case of, say, >> >> mpfr_init2(self._args[f(i)], self.domain.prec()) >> >> where f is a cdef int -> int function. Do we handle that? > > Sure. The problem isn't (any longer) that we *forget* to put things into a > temp, the problem is that we try to put things into a temp now that we > cannot store away. > > I've been dropping some cases in my latest commits where the temp copying > mechanism was triggered needlessly. It's basically a matter of properly > implementing is_simple() for an ExprNode in order to decide when a non-temp > result is side-effect free. > > I'm still not sure if a coerce_to_owned() method would be worthwhile. As > long as SimpleCallNode is the only place where this is actually needed, > it's fine to leave the code there. Can anyone think of other places where > the order of C value evaluation matters? Tuples and other container > literals may qualify, but given that they use only Python values, I don't > see it being a problem there.
I'm not sure we handle the optimization of, e.g, "a in (x, y, z)" There might be others as well. Fixing Sage is turning out to be non-trivial...there are many places that assume mpz_t is (compatible with) a void*. We also have the problem that Cython doesn't let you take the address of an array, as it is a non-lvalue, but that's legal in C (and used in Sage). - Robert _______________________________________________ Cython-dev mailing list Cython-dev@codespeak.net http://codespeak.net/mailman/listinfo/cython-dev