I like to use np.fromiter from numpy because it is a resource-lazy way to create np.array objects. However, it does not seem to support multidimensional arrays, which are also quite useful.
import numpy as np def fun(i): """ A function returning 4 values of the same type. """ return tuple(4*i + j for j in range(4))
How can I get a as a multidimensional array while preserving such a lazy generator-based construct?
python arrays numpy multidimensional-array lazy-evaluation
iago-lito
source share