[SciPy-User] Size of sparse boolean coo_matrix unexpectedly tiny

DoanVietTrungAtGmail doanviettrung at gmail.com
Tue Mar 26 19:37:02 EDT 2013


I created an NxN (N = 10^6) sparse boolean coo_matrix A and randomly filled
it with 200,000 Trues. sys.getsizeof(A) said A took 32 bytes - a thousand
times smaller than I expected. I am new to Scipy, please tell me what's
going on, thanks.

>>> rows = [random.randint(0,999999) for j in xrange(200000)]
>>> cols = [random.randint(0,999999) for j in xrange(200000)]
>>> vals = ones_like(rows)
>>> A = sparse.coo_matrix((vals,(rows,cols)), shape = (int(1E6), int(1E6)),
dtype = bool)
>>> len(vals)
200000
>>> print sys.getsizeof(A)
32
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20130327/6cf366e8/attachment.html>


More information about the SciPy-User mailing list