简体   繁体   中英

why does getsizeof a float num return 16 in python

>>> x=float(12.345)
>>> x
12.345
>>> sys.getsizeof(x)
16
>>> sys.getsizeof(12.345)
16

Here 16 is of the unit of byte? But in the document it's of 64 bits the float

python 3.5.1 32bits Windows 7 64

sys.getsizeof() returns the memory size of an instance of the float type. In addition to the 8 bytes used by the 64-bit IEEE representation of a float, additional memory is used for reference count, a pointer to type information, etc.

The memory space consumed by a python variable depends on the what version of python you have ie. 32 bit or 64 bit platform.

Coming to float representation. A float in 32 bit python consumes 16 bytes of memory while for 64 bit it consumes 24 byte of memory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM