python 基本數(shù)據(jù)類型占用內(nèi)存空間大小的實(shí)例
python中基本數(shù)據(jù)類型和其他的語言占用的內(nèi)存空間大小有很大差別
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 基本數(shù)據(jù)類型占用內(nèi)存空間大小的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
使用scrapy實(shí)現(xiàn)爬網(wǎng)站例子和實(shí)現(xiàn)網(wǎng)絡(luò)爬蟲(蜘蛛)的步驟
本文分二個(gè)示例,第一個(gè)是個(gè)簡(jiǎn)單的爬網(wǎng)站的小例子,第二個(gè)例子實(shí)現(xiàn)目是從一個(gè)網(wǎng)站的列表頁抓取文章列表,然后存入數(shù)據(jù)庫中,數(shù)據(jù)庫包括文章標(biāo)題、鏈接、時(shí)間,大家參考使用吧2014-01-01
解決PyCharm同目錄下導(dǎo)入模塊會(huì)報(bào)錯(cuò)的問題
今天小編就為大家分享一篇解決PyCharm同目錄下導(dǎo)入模塊會(huì)報(bào)錯(cuò)的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-10-10
python循環(huán)神經(jīng)網(wǎng)絡(luò)RNN函數(shù)tf.nn.dynamic_rnn使用
這篇文章主要為大家介紹了python循環(huán)神經(jīng)網(wǎng)絡(luò)RNN的tf.nn.dynamic_rnn使用示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05
PyTorch中的C++擴(kuò)展實(shí)現(xiàn)
這篇文章主要介紹了PyTorch中的C++擴(kuò)展實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-04-04
Pyecharts 動(dòng)態(tài)地圖 geo()和map()的安裝與用法詳解
這篇文章主要介紹了Pyecharts 動(dòng)態(tài)地圖 geo()和map()的安裝與用法詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03

