[Numpy-discussion] Best dtype for Boolean values

John Jack itsmilesdavis at gmail.com
Mon Apr 12 11:59:46 EDT 2010


Hello all.

I am (relatively) new to python, and 100% new to numpy.

I need a way to store arrays of booleans and compare the arrays for
equality.

I assume I want arrays of dtype Boolean, and I should compare the arrays
with array_equal

>>> tmp.all_states
array([False,  True, False], dtype=bool)
>>> tmp1.all_states
array([False, False, False], dtype=bool)
>>> tmp1.all_states[1]=True
>>> tmp1.all_states
array([False,  True, False], dtype=bool)
>>> array_equal(tmp.all_states,tmp1.all_states)
True
>>> any(tmp.all_states)
True

Would this be (a) the cheapest way (w.r.t. memory) to store Booleans and (b)
the most efficient way to compare two lists of Booleans?

Thanks for your advice.
-JJ.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100412/a97162d1/attachment.html>


More information about the NumPy-Discussion mailing list