i ran into something interesting about the python augmented assignment +=
it seems to be automatic data type conversion is not always done for a += b if a is a 'simpler' data type, while a = a + b seems to work always
cases where the conversion is done
a = 1
b = 1j
a = 1
b = 0.5
case where the conversion is not done
from numpy import array
a = array([0, 0 ,0])
b = array([0, 0, 1j])
after a += b, a remains as integer matrix, instead of complex matrix
i used to think a += b is the same as a = a + b, what is the difference of them in the underlying implementation?
arrayin your example refer to? Is that from the builtinarraymodule? if so, your example doesn't even work, since there's no typecode...a = array([0, 0 ,0])andb = array([0, 0, 1j])don't work with thearrayclass in the module of the same name. They're both missing an initial typecode argument. And, AFAIK, the class doesn't support complex numbers nor+=augmented assignment. So I don't understand what you're asking here.