#19555: Implement a containment for cartesian_product
-------------------------------------+-------------------------------------
       Reporter:  tscrim             |        Owner:  sage-combinat
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.10
      Component:  combinatorics      |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Travis Scrimshaw   |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  public/sets/contains_cartesian_product-19555|  
6a440d55060e2a7debbed41b22990951d8a3c6a5
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by tscrim):

 Ahh...the speed of Cython. I created a new class in between
 `ElementWrapper` and `CartesianProduct.Element` that has specialized
 equality comparisons against the wrapped class.

 Current:
 {{{
 sage: C = cartesian_product([ZZ, ZZ])
 sage: c = C((1, 1))
 sage: d = C((1, 1))
 sage: e = C((1, 2))
 sage: %timeit c == d
 1000000 loops, best of 3: 183 ns per loop
 sage: %timeit c == e
 10000000 loops, best of 3: 183 ns per loop
 }}}
 vs old:
 {{{
 sage: %timeit c == d
 1000000 loops, best of 3: 175 ns per loop
 sage: %timeit c == e
 10000000 loops, best of 3: 179 ns per loop
 }}}
 So we might loose up to ~2%, but I think this will get lost in noise if
 someone is doing Cartesian products of things with any harder comparison
 operators. (Although IMO the previous slowdown would likely have been
 negligible in computations (at least I would recommend using `itertools`
 and `tuple`s if this was an issue)).

 As suggested in the parenthetical, if you wanted this to be a facade
 parent for tuples, which is I think what you would end up with, then you
 likely could just use `itertools`.

--
Ticket URL: <http://trac.sagemath.org/ticket/19555#comment:19>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" 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-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to