Static variable vs Class variable
Hrvoje Niksic
hniksic at xemacs.org
Wed Oct 17 10:05:02 EDT 2007
Duncan Booth <duncan.booth at invalid.invalid> writes:
> Hrvoje Niksic <hniksic at xemacs.org> wrote:
>
>> The current implementation of += uses __add__ for addition and
>> __iadd__ for addition that may or may not be in-place. I'd like to
>> know the rationale for that design.
>>
>
> Apart from the obvious short answer of being consistent (so you don't
> have to guess whether or not a+=b is going to do an assignment), I think
> the decision was partly to keep the implementation clean.
The implementation, by necessity, supports a lot of historical cruft,
so keeping it clean was not a priority. (This is not a criticism, I
like how they kept backward compatibility.)
> Right now an inplace operation follows one of three patterns:
[...]
Thanks for pointing it out; I didn't realize just how much work went
into the new assignment opcodes. Given the complexity, it's a wonder
they're there at all!
More information about the Python-list
mailing list