[Numpy-discussion] Singleton bool_ values

Sasha ndarray at mac.com
Wed Jan 18 12:09:07 CST 2006


As of svn version 1931, numpy bool_ values are singletons:
>>> from numpy import *
>>> bool_(0) is array([True,False])[1]

This change makes bool_ values behavior more similar to python bools
and will allow much faster implementation of scalar boolean algebra. 
In order to allow other modules to take advantage of this property, I
would like to propose several additions to python and c interfaces.

At the Python level: define True_ and False_ constants.
At the C-API level:
PyArrayScalar_True
PyArrayScalar_False
PyArrayScalar_BoolFromLong
PyArrayScalar_RETURN_TRUE
PyArrayScalar_RETURN_FALSE
PyArrayScalar_RETURN_BOOL_FROM_LONG

Any objections?

-- sasha




More information about the Numpy-discussion mailing list