I want to create an object in python that is a collection of around 200,000,000 true/false values. So that I can most effectively change or recall any given true/false value, so that I can quickly determine if any given number, like 123,456,000 is true or false or change its value.
Is the best way to do this a list? or an array? or a class? or just a long int using bit operations? or something else?
I'm a bit noob so you may have to spell things out for me more than if I were asking the question in one of the other languages I know better. Please give me examples of how operating on this object would look.
Thanks
You can try the bitarray
module, or write a similar thing using an array
of integers yourself.
"quickly determine if any given number, like 123,456,000 is" in the "true" set or "false" set.
This is what a set is for.
The "true" set is a set of all the numbers.
To make a number's boolean flag "true", add it to the true set.
To make a number's boolean flag "false", remove it from the true set.
Life will be much simpler.
Have you considered using a lightweight database like SQLite?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With