Does anybody know how much memory is used by a numpy ndarray? (with let’s say 10,000,000 float elements).
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The array is simply stored in one consecutive block in memory. Assuming by “float” you mean standard double precision floating point numbers, then the array will need 8 bytes per element.
In general, you can simply query the
nbytesattribute for the total memory requirement of an array, anditemsizefor the size of a single element in bytes:In addtion to the actual array data, there will also be a small data structure containing the meta-information on the array. Especially for large arrays, the size of this data structure is negligible.