The timing differences between "any" and "exists" still bother me a bit, so I tried plain sage -ipython:
sage: def exists(S, P): ...: for x in S: ...: if P(x): return True, x ...: ...: return False, None sage: L=range(10^6) sage: L[10^6-3]=-1 sage: g=lambda a: a<0 sage: %timeit any(g(a) for a in L) 100000 loops, best of 3: 7.09 µs per loop sage: %timeit exists(L, g) 100000 loops, best of 3: 4.44 µs per loop sage: %timeit any(a<0 for a in L) 100000 loops, best of 3: 4.57 µs per loop sage: %timeit exists(L, lambda a: a<0) 100000 loops, best of 3: 4.86 µs per loop The differences are crazy. Assigning a lambda expression to an identifier speeds things up? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
