存储布尔值最好的方式保存在内存中的Python [英] Best way to store boolean values to save memory in python

查看:136
本文介绍了存储布尔值最好的方式保存在内存中的Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是由一个长号索引像采集字典一百万至450,000布尔值之间存储的最佳方式?我需要使用的内存可能最少。真和Int都占用每个条目超过22个字节。有每一个布尔值较低的内存可能吗?

What is the best way to store between a million to 450,000 Boolean values in a dictionary like collection indexed by a long number? I need to use the least amount of memory possible. True and Int both take up more than 22 bytes per entry. Is there a lower memory per Boolean possible?

推荐答案

问题。 Bitarray 似乎是preferred选择。

Check this question. Bitarray seems to be the preferred choice.

这篇关于存储布尔值最好的方式保存在内存中的Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆