I want to be able to \'build\' a numpy array on the fly, I do not know the size of this array in advance.
For example I want to do something like this:
For posterity, I think this is quicker:
a = np.array([np.array(list()) for _ in y])
You might even be able to pass in a generator (i.e. [] -> ()), in which case the inner list is never fully stored in memory.
Responding to comment below:
>>> import numpy as np
>>> y = range(10)
>>> a = np.array([np.array(list) for _ in y])
>>> a
array([array(, dtype=object),
array(, dtype=object),
array(, dtype=object),
array(, dtype=object),
array(, dtype=object),
array(, dtype=object),
array(, dtype=object),
array(, dtype=object),
array(, dtype=object),
array(, dtype=object)], dtype=object)