Is there a way in numpy to create an array of booleans that uses just 1 bit for each entry?
The standard np.bool type is 1 byte, but this way I use 8 times the required memory.
On Google I found that C++ has std::vector<bool>.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You might like to take a look at bitstring (documentation here).
If you create a
ConstBitArrayorConstBitStreamfrom a file then it will usemmapand not load it into memory. In this case it won’t be mutable so if you want to make changes it will have to be loaded in memory.For example to create without loading into memory:
or