literals optimization (was Re: append on lists)
Maric Michaud
maric at aristote.info
Tue Sep 16 12:47:02 EDT 2008
Le Tuesday 16 September 2008 18:26:38 Grant Edwards, vous avez écrit :
> I was asking where in the specification
> <http://docs.python.org/ref/ref.html> it says that all expressions that
> return something, return a
> new object.
I never said this, I said it's the spirit of python APIs, with some noticeable
exceptions (see my first post).
But for this case specifically, a + b *should* return a new object, see the
documentation of __add__ and __iadd__ special methods, it's clearly stated.
The fact that an integer with value "1" is always the same integer in some
implementation is unrelated to the original problem.
--
_____________
Maric Michaud
More information about the Python-list
mailing list