Is behavior of += intentional for int?
szport at gmail.com
Tue Sep 1 16:04:09 CEST 2009
On 1 сен, 03:31, Steven D'Aprano <st... at REMOVE-THIS-
> On Mon, 31 Aug 2009 10:21:22 -0700, zaur wrote:
> > As a result of this debate is not whether we should conclude that there
> > should be two types of integers in python: 1) immutable numbers, which
> > behave as constant value; 2) mutable numbers, which behave as variable
> > value?
> What can you do with mutable numbers that you can't do with immutable
> ones, and why do you want to do it?
Mutable numbers acts as variable quantity. So when augmented
assignment is used there is no need to create a new number object in
every binary operation.
But when I looked now into source of python int (longobject.c) I
realized that direct implementation of mutable int will not give any
benefit against defining proxy int class, which supports mutability.
More information about the Python-list