#8766: document the _iadd_ and _imul_ special integer.pyx methods, which mutate
self
--------------------------------+-------------------------------------------
   Reporter:  was               |       Owner:  AlexGhitza
       Type:  defect            |      Status:  new       
   Priority:  major             |   Milestone:  sage-4.4.2
  Component:  basic arithmetic  |    Keywords:            
     Author:                    |    Upstream:  N/A       
   Reviewer:                    |      Merged:            
Work_issues:                    |  
--------------------------------+-------------------------------------------

Comment(by was):

 {{{
 > This is odd. From their names one would expect them to be used in
 __imul__
 > and __iadd__ somewhere in the hierarchy, just like _repr_ is used in
 > __repr__, so that they will be used for:
 >
 > sage: a = 1
 > sage: a*=5
 >
 > as documented here: http://docs.python.org/reference/datamodel.html.
 > However, this is not the case. It may be a bug (or yet to be implemented
 > feature).

 That is not a bug -- it is done on purpose.  The reason is because
 integers are meant to be *immutable*, since they have a hash method.   If
 _imul_ were used by __imul__, then people would be mutating integers left
 and right by accident, and vast amounts of code would consequently have
 subtle bugs all over the place.

 There might have been a time (maybe a few weeks in 2006) when __imul__ did
 indeed call _imul_ in Sage, so the name might be a historical remnant.

 Personally, I think the best thing would be:

   (1) Rename _imul_ and _iadd_ to something like _unsafe_inplace_mul_,
 _unsafe_inplace_add_

   (2) Document them.

 William
 }}}

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