[Numpy-discussion] How to concatenate two arrayswithout duplicating memory?

"V. Armando Solé" sole at esrf.fr
Wed Sep 2 05:31:06 EDT 2009


Citi, Luca wrote:
> As Gaël pointed out you cannot create A, B and then C
> as the concatenation of A and B without duplicating
> the vectors.
>   
> But you can still re-link A to the left elements
> and B to the right ones afterwards by using views into C.
>   

Thanks for the hint. In my case the A array is already present and the 
contents of the B array can be read from disk.

At least I have two workarounds making use of your suggested solution of 
re-linking:

- create the C array, copy the contents of A to it and read the contents 
of B directly into C with duplication of the memory of A during some time.

- save the array A in disk, create the array C, read the contents of A 
and B into it and re-link A and B with no duplication but ugly.

Thanks,

Armando





More information about the NumPy-Discussion mailing list