On 01/02/2008, John Cremona <[EMAIL PROTECTED]> wrote: > any() ans all() certainly deserve to be better known. In the patch I > submitted yesterday including the file > sage/rings/number_field/number_field_ideal.py there's a whole > function, doctest and all, called > def is_pari_zero_vector(z): > which can be replaced entirely by "not all(z)".
I meant: "not any(z)". > John > > On 01/02/2008, Nils Bruin <[EMAIL PROTECTED]> wrote: > > > > I forgot one case. This is weird. Exists seems *faster* than any. That > > should never be happening! > > > > 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.47 s per loop > > sage: %timeit exists(L, lambda a: a<0) > > 10 loops, best of 3: 2.83 s per loop > > sage: g=lambda a: a<0 > > sage: %timeit any(g(a) for a in L) > > 10 loops, best of 3: 1.19 s per loop > > sage: %timeit exists(L, g) > > 10 loops, best of 3: 1.04 s per loop > > > > > > > > > > > > > -- > John Cremona > -- John Cremona --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
