I\'m using numpy to create a cube array with sides of length 100, thus containing 1 million entries total. For each of the million entries, I am inserting a 100x100 matrix w
A couple points:
cube.dtype
is int64
, and it has 1,000,000 elements, it will require 1000000 * 64 / 8 = 8,000,000
bytes (8Mb).cube
, element = matrix
will simply overwrite the element
variable, leaving the cube
unchanged. The same goes for the entry = random.rand() * 100
.for the "inner" part of your function, look at the numpy.random module
import numpy as np
matrix = np.random.random((100,100))*100