Hi Jori, On 2014-09-14, Jori Mantysalo <[email protected]> wrote: > I was just playing with posets. Let L=Posets(7). Then > > len([x for x in L if x.is_lattice()]) > > takes about two times more time than > > len([x for x in L if x.is_bounded() and x.is_lattice()])
I can not replicate your result. sage: %time len([x for x in L if x.is_lattice()]) CPU times: user 47.4 s, sys: 40 ms, total: 47.4 s Wall time: 48.9 s 53 sage: %time len([x for x in L if x.is_lattice()]) CPU times: user 46.9 s, sys: 7 ms, total: 46.9 s Wall time: 47 s 53 sage: %time len([x for x in L if x.is_bounded() and x.is_lattice()]) CPU times: user 45.8 s, sys: 19 ms, total: 45.8 s Wall time: 45.9 s 53 sage: %time len([x for x in L if x.is_bounded() and x.is_lattice()]) CPU times: user 45.6 s, sys: 35 ms, total: 45.6 s Wall time: 45.7 s 53 So, very far from factor two. > Is this just some marginal and uninterestin case, or is algorithm badly > chosen, or is is_lattice() meant to be used in situations where posets > usually are bounded? First of all, it suprises me that it takes so long, but this could be since I am no expert and don't know if it is a difficult problem. Generally, when you test `x.is_bounded() and x.is_lattice()` and `x.is_bounded()` is False, then `x.is_lattice()` will not be called. That could explain some difference in timings. Moreover, it is a possibility that some partial results are cached (that's why I repeated the timing above twice). In particular, it could be that while computing "x.is_bounded()", some partial information is computed and cached that is also needed in x.is_lattice(). But anyway, I can't seem to reproduce what you observed. Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
