Python3 基本类型在64位上的占用内存情况

基本类型占用的内存

类型

# -*- coding: utf-8 -*- # @Time : 2019-12-19 11:16 # @Author : binger import sys a = None b = 1000.2311 c = 1000 d = True e = "" f = () g = [] h = set([]) i = {} 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)), sys.getsizeof("12")) print(" %s size is %d " % (type(f), sys.getsizeof(f)), sys.getsizeof((1,))) print(" %s size is %d " % (type(g), sys.getsizeof(g)), sys.getsizeof([1, ])) print(" %s size is %d " % (type(h), sys.getsizeof(h)), sys.getsizeof(set([1, ]))) print(" %s size is %d " % (type(i), sys.getsizeof(i)), sys.getsizeof({1: 1}))

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwzzfs.html