[cctbxbb] Inconsistency between numpy and flex (sclice notation)
Luc Bourhis
luc_j_bourhis at mac.com
Tue Jan 3 07:50:05 PST 2012
On 3 Jan 2012, at 16:29, Jan Marten Simons wrote:
> Ok, so if I want to do many (writing) operations on sclices of the miller
> array it would be best to copy/convert it into a numpy array first, so I don't
> have the overhead of the individual copy operations then.
No, write operations are done directly on the array on which you use the slicing notation:
grild[1:2, :] = flex.double(...)
will incur the memory allocation of the right-hand side but then there is no extra temporary array involved.
My point was just that in:
for x in grid[1:2, :]:
....
there is the allocation and initialisation of a temporary array that holds the slice. In numpy, grid[1:2,:] would behave like an iterator in this context and there would be no temporary array.
Luc
More information about the cctbxbb
mailing list