[c-api]Transmutation of an extension object into a read-only buffer adding an integer in-place.

Hans Mulder hansmu at xs4all.nl
Fri Aug 10 14:21:50 CEST 2012

On 10/08/12 11:25:36, Giacomo Alzetta wrote:
> Il giorno venerdì 10 agosto 2012 11:22:13 UTC+2, Hans Mulder ha scritto:
> Yes, you're right. I didn't thought the combined operator would do a Py_DECREF
> if the iadd operation was implemented, but it obviosuly makes sense.

The += operator cannot know if the iadd returns self or a newly created
object.  Mutable types usually do the former; non-mutable types must do
the latter.

Come to think of it: why are your polynomials mutable?

As a mathematician, I would think of polynomials as elements of
some kind of ring, and I'd expect them to be non-mutable.

-- HansM

More information about the Python-list mailing list