python 基本数据类型占用内存空间大小的实例
更新时间:2018年06月12日 08:37:44 作者:ben1949
今天小编就为大家分享一篇python 基本数据类型占用内存空间大小的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
python中基本数据类型和其他的语言占用的内存空间大小有很大差别
import sys
a = 100
b = True
c = 100L
d = 1.1
e =""
f = []
g =()
h = {}
i = set([])
print " %s size is %d "%(type(a),sys.getsizeof(a))
print " %s size is %d "%(type(b),sys.getsizeof(b))
print " %s size is %d "%(type(c),sys.getsizeof(c))
print " %s size is %d "%(type(d),sys.getsizeof(d))
print " %s size is %d "%(type(e),sys.getsizeof(e))
print " %s size is %d "%(type(f),sys.getsizeof(f))
print " %s size is %d "%(type(g),sys.getsizeof(g))
print " %s size is %d "%(type(h),sys.getsizeof(h))
print " %s size is %d "%(type(i),sys.getsizeof(i))
<type 'int'> size is 12
<type 'bool'> size is 12
<type 'long'> size is 14
<type 'float'> size is 16
<type 'str'> size is 21
<type 'list'> size is 36
<type 'tuple'> size is 28
<type 'dict'> size is 140
<type 'set'> size is 116
以上这篇python 基本数据类型占用内存空间大小的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
python循环神经网络RNN函数tf.nn.dynamic_rnn使用
这篇文章主要为大家介绍了python循环神经网络RNN的tf.nn.dynamic_rnn使用示例,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2022-05-05
Pyecharts 动态地图 geo()和map()的安装与用法详解
这篇文章主要介绍了Pyecharts 动态地图 geo()和map()的安装与用法详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2020-03-03


最新评论