Changes to bools under Numexpr

Ivan Vilata i Balaguer ivilata at
Thu Oct 26 06:57:37 CDT 2006

Hi all.  The attached diff makes some changes to Numexpr support for
booleans.  The changes and their rationale are below.

1. New ``True`` and ``False`` boolean constants.  This is so that 1 and
   0 are always proper integer constants.  It is also for completeness,
   but I don't envision any usage for them that couldn't be expressed
   without the constants.

2. The only comparisons supported with booleans are ``==`` and ``!=``,
   so that you can compare boolean variables.  Just as NumPy supports
   complex order comparisons and Numexpr doesn't, so goes for bools.
   Being relatively new, I think there is no need to keep
   integer-boolean compatibility in Numexpr.  What was the meaning of
   ``True > False`` or ``2 > True`` anyway?

3. This is also why casting booleans to normal numbers is not allowed,
   so ``prod()`` and ``sum()`` on booleans aren't either.  What is the
   meaning of boolean addition anyway?

To make it short, this patch is kind of a strengthening of boolean
values.  I expect some people to disagree with the changes, and that's
why I would really like to hear your opinions on it.



	Ivan Vilata i Balaguer   >qo<
	       Cárabos Coop. V.  V  V   Enjoy Data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: numexpr-bool2.diff
Type: text/x-patch
Size: 8581 bytes
Desc: not available
Url : 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 309 bytes
Desc: OpenPGP digital signature
Url : 
-------------- next part --------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
-------------- next part --------------
Numpy-discussion mailing list
Numpy-discussion at

More information about the Numpy-discussion mailing list