[SciPy-dev] In-place operators and casting
Alan G Isaac
aisaac at american.edu
Thu Nov 24 08:02:52 CST 2005
On Thu, 24 Nov 2005, Ed Schofield apparently wrote:
>>> c = zeros(10)
>>> c += rand(10)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
Having that result differ from the result of
c=array([ci+ri for ci,ri in zip(c,rand(10))])
certainly feels weird. I doubt anyone expects or wants the
current behavior except those who have already been bitten,
figured it out, and then got used to it.
That said, there seems to be a conflict between a
"user friendly" approach and the possible fixes.
I think the "user friendly" approach would be a flag that
sets the default return type of scipy functions (like zeros)
Anyway, in this case I favor an exception.
Otherwise users will be constantly surprised.
More information about the Scipy-dev