On Jan 31, 6:50 pm, "William Stein" <[EMAIL PROTECTED]> wrote:

[...]
> Also, in your posted patch you emphasize that forall and exists
> are *NOT* suitable for use in an if, etc.  I would have written that
> to use them thus you have to use the ugly forall(...)[0], and it is
> much nicer to use all(...) and any(...).
[...]

sage: L=[1..10^6]
sage: L[10^6-3]=-1
sage: %timeit any(a<0 for a in L)
10 loops, best of 3: 2.44 s per loop
sage: %timeit exists(L, lambda a: a<0)
10 loops, best of 3: 2.84 s per loop
sage: g=lambda a: a<0
sage: %timeit any(g(a) for a in L)
10 loops, best of 3: 1.14 s per loop

If you don't need the witness, you should not be using "exists". It's
a bit weird the lambda clause actually speeds things up in "any".
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to