#9089: Graphics3dGroup __add__ modifies its arguments
---------------------------+------------------------------------------------
   Reporter:  jason        |       Owner:  jason, was  
       Type:  defect       |      Status:  needs_review
   Priority:  major        |   Milestone:  sage-4.4.3  
  Component:  graphics     |    Keywords:              
     Author:  Jason Grout  |    Upstream:  N/A         
   Reviewer:               |      Merged:              
Work_issues:               |  
---------------------------+------------------------------------------------

Comment(by jason):

 Before patch:

 {{{
 sage: from sage.misc.misc import balanced_sum
 sage: from sage.plot.plot3d.base import Graphics3dGroup
 sage: lines=[line3d([[0,0,0],[cos(t),sin(t),1]]) for t in [0,0.05,..,6]];
 len(lines)
 121
 sage: %timeit p=sum(lines)
 625 loops, best of 3: 82.1 µs per loop
 sage: lines=[line3d([[0,0,0],[cos(t),sin(t),1]]) for t in [0,0.05,..,6]];
 len(lines)
 121
 sage: %timeit p=balanced_sum(lines)
 625 loops, best of 3: 455 µs per loop
 sage: lines=[line3d([[0,0,0],[cos(t),sin(t),1]]) for t in [0,0.05,..,6]];
 len(lines)
 121
 sage: %timeit p=Graphics3dGroup(lines)
 625 loops, best of 3: 179 µs per loop
 }}}


 After patch:

 {{{

 sage: from sage.misc.misc import balanced_sum
 sage: from sage.plot.plot3d.base import Graphics3dGroup
 sage: lines=[line3d([[0,0,0],[cos(t),sin(t),1]]) for t in [0,0.05,..,6]];
 len(lines)
 121
 sage: %timeit p=sum(lines)
 625 loops, best of 3: 1.48 ms per loop
 sage: lines=[line3d([[0,0,0],[cos(t),sin(t),1]]) for t in [0,0.05,..,6]];
 len(lines)
 121
 sage: %timeit p=balanced_sum(lines)
 625 loops, best of 3: 1.45 ms per loop
 sage: lines=[line3d([[0,0,0],[cos(t),sin(t),1]]) for t in [0,0.05,..,6]];
 len(lines)
 121
 sage: %timeit p=Graphics3dGroup(lines)
 625 loops, best of 3: 180 µs per loop

 }}}

 So, as could be expected, performance of sum is impacted quite a bit.
 However, I would still say that the current behavior is wrong, and
 correctness trumps speed, especially if the overall total speed is still
 quite fast.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9089#comment:4>
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 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-trac?hl=en.

Reply via email to