Skip to content Skip to sidebar Skip to footer

Implementing Nb_inplace_add Results In Returning A Read-only Buffer Object

I'm writing an implementation of the in-place add operation. But, for some reason, I sometimes get a read-only buffer as result(while I'm adding a custom extension class and an int

Solution 1:

According to the documentation, the inplace add operation for an object returns a new reference.

By returning self directly without calling Py_INCREF on it, your object will be freed while it is still referenced. If some other object is allocated the same piece of memory, those references would now give you the new object.

Post a Comment for "Implementing Nb_inplace_add Results In Returning A Read-only Buffer Object"