def five(i):
"""turns a number into an at least five-digit string"""
s = hex(s).replace('0x', '')
return '0' * (5 - len(s)) + s
# 500k items, no duplication
d = {}
for i in range(500000):
d[i] = five(i)
# see https://code.activestate.com/recipes/577504/
total_size(d, verbose=False) / 1024 / 1024
# => 33.8720645904541 (megabytes)
好的,你有50万个项目,其中一个数字对应一个五位数的字符串:
让我们来检验一下
没什么,真的。用口述
相关问题 更多 >
编程相关推荐