'Is there a way to build a numpy view or similar from several 1d arrays instead of concatting them into a matrix?

Consider

import numpy as np
a = np.random.randn(3)
b = np.random.randn(3)
c = np.vstack([a, b])  # this always create a copy of a and b I think

Is there a fast way of assembling some c that is just pointers to the space by a and b?

Basically I have some situation where I can do a fairly cheap first pass to determine the total number of vectors I will have or I can just store a list/dict of vectors and assemble on the fly for something. If there was a cheap way of doing that I would save the first pass.

The answer is no it is not possible. And there is a similar (duplicate) question here Concatenate Numpy arrays without copying .



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source