Is behavior of += intentional for int?
steve at REMOVE-THIS-cybersource.com.au
Wed Sep 2 01:00:06 CEST 2009
On Tue, 01 Sep 2009 07:04:09 -0700, zaur wrote:
> On 1 сен, 03:31, Steven D'Aprano <st... at REMOVE-THIS- cybersource.com.au>
>> 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 do immutable numbers bound to a name.
> So when augmented assignment
> is used there is no need to create a new number object in every binary
"No need", sure, but there's no *need* to use object oriented code in the
first place, or garbage collectors, or high level languages, or even
functions. People got by with GOTO and assembly for years :) We use all
these things because they make *programming* easier, even if it adds
I'm asking what *problem* you are trying to solve with mutable numbers,
where immutable numbers are not satisfactory. The only answer I can
imagine is that you're worried about the overhead of creating new integer
objects instead of just flipping a few bits in an existing integer
More information about the Python-list