From time to time I find myself overwriting a python buffer with the output of a ufunc, for example like this:
import array import numpy as np a = array.array('f', (1,1,1)) np.exp2(a, out=np.asarray(a)) assert a.tolist() == [2, 2, 2] Here I have to wrap `out=np.asarray(a)` because the more natural `np.exp2(a, out=a)` raises "TypeError: return arrays must be of ArrayType” In general, ufuncs are quite aggressive in utilizing the buffer protocol for input arguments. I was wondering, why are they so reluctant to do the same for the output argument? Is this a design choice? Efficiency? Legacy? Would be implementing `np.ufunc(a, out=a)` dangerous or cumbersome? Stefano
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com