#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|  
f1d029a3a3518265f1f88c2438bbc9b00c7ecd36
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by vdelecroix):

 I fully agree on the above example and there are many others. As you said,
 wrapping has a cost. Having an option looks reasonable
 {{{
 sage: C = cartesian_product([range(5), range(5)],
 with_elements_as_tuple=True)
 sage: C.element_class
 <type 'tuple'>
 }}}
 Though, I am just asking for your opinion. I am not considering it good
 for inclusion in this ticket.

 On the other hand, with your laxism with respect to tuples the equality
 test is about 3x slower. We had
 {{{
 sage: C = cartesian_product([srange(5), srange(5)])
 sage: c = C((1,1))
 sage: d = C((1,1))
 sage: e = C((1,2))
 sage: %timeit c == d and c == e
 1000000 loops, best of 3: 327 ns per loop
 }}}
 And with your branch
 {{{
 sage: %timeit c == d and c == e
 100000 loops, best of 3: 1.93 µs per loop
 }}}
 If the comparison has to be touched, it has to be at the level of
 `ElementWrapper`. Probably a new class.

--
Ticket URL: <http://trac.sagemath.org/ticket/19555#comment:17>
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