I ran this on my Mac (OS 10.13, 16GB RAM, 512GB SSD) and had the same, successful results that you did.
This comment seems like a possible answer.
In summary: since you're using zeros()
, there's no need to have each cell of the matrix take up 4 bytes when they all have the same value. Rather, behind the scenes, numpy may be explicitly storing in memory all values in the matrix that are not equal to a common value (in this case, zero).
Worth noting that running np.random.rand(1000000000, 3000)
causes some havoc on my Mac, which does the same thing as zeros()
but fills the matrix with actual data. RAM gets maxed out, then begins to use the swap partition.
Before np.random.rand()
:

During np.random.rand()
:
