Is there a reference for the memory size of Python data stucture on 32- and 64-bit platforms?
If not, this would be nice to have it on SO. The more exhaustive the better! So how many bytes are used by the following Python structures (depending on the len
and the content type when relevant)?
int
float
- reference
str
- unicode string
tuple
list
dict
set
array.array
numpy.array
deque
- new-style classes object
- old-style classes object
- ... and everything I am forgetting!
(For containers that keep only references to other objects, we obviously do not want to count the size of the item themselves, since it might be shared.)
Furthermore, is there a way to get the memory used by an object at runtime (recursively or not)?
a
, usea.nbytes
. – Preform