On Tue, 21 Feb 2006 12:44:52 +0530 in comp.lang.python, Suresh Jeevanandam <[EMAIL PROTECTED]> wrote:
># I am new to python. > >In python all numbers are immutable. This means there is one object ( a >region in the memory ) created every time we do an numeric operation. I >hope there should have been some good reasons why it was designed this way. > >But why not have mutable numbers also in the language. A type which >would behave as follows: > >a = MutableInt(12) a = [12] >b = a > >Now both a and b should refer to the same memory location. Any change in >the object should get reflected in all the references. > >a.assign(13) # Same memory location should be updated with value 13, b a[0] = 13 >is also 13 now. > >Now we can further optimize: > >a.incrementOne() # equivalent to a++ in C++ >a.decrementOne() a[0] += 1 a[0] -= 1 > >and the augmented assignment operation also could be made optimized. > >In any application most of the operation is numerical. So, i think, we >should get a good speed advantage with the availability of mutable >numbers. What do you think ? I don't see how. HTH, -=Dave -- Change is inevitable, progress is not. -- http://mail.python.org/mailman/listinfo/python-list