Hi, In the numarray source code Bool is defined as a typedef to char. Does the Bool array type correspond to the Int8, or the UInt8 type? If I recall correctly, the char type may be signed or unsigned. Can I make any assumptions about the C type used to implement Bool at all? I guess at the Python level it does not matter what actual C type is used to implement bool arrays as it only represents boolean values. However, at the level of C extensions I would like to deal with Bool arrays by calling existing functions written for the appropiate C type. That would be somewhat simpler if Bool is always garantueed to be either a unsigned or a signed char type. Cheers, Peter. -- Dr. Peter J. Verveer Cell Biology and Cell Biophysics Programme EMBL Meyerhofstrasse 1 D-69117 Heidelberg Germany Tel. : +49 6221 387245 Fax : +49 6221 387242 Email: Peter.Verveer@embl-heidelberg.de
Peter Verveer wrote:
Hi,
In the numarray source code Bool is defined as a typedef to char. Does the Bool array type correspond to the Int8, or the UInt8 type? If I recall correctly, the char type may be signed or unsigned. Can I make any assumptions about the C type used to implement Bool at all?
Yes! It's named Bool. :)
I guess at the Python level it does not matter what actual C type is used to implement bool arrays as it only represents boolean values. However, at the level of C extensions I would like to deal with Bool arrays by calling existing functions written for the appropiate C type.
The easiest way now is to just declare your variables with type "Bool". The only thing I can think of which that doesn't cover is printf/scanf. Are there others?
That would be somewhat simpler if Bool is always garantueed to be either a unsigned or a signed char type.
I think perhaps we should just re-define Bool as signed char. Any other opinions?
Cheers, Peter.
Todd
On Tuesday 06 May 2003 17:48, Todd Miller wrote:
Peter Verveer wrote:
Hi,
In the numarray source code Bool is defined as a typedef to char. Does the Bool array type correspond to the Int8, or the UInt8 type? If I recall correctly, the char type may be signed or unsigned. Can I make any assumptions about the C type used to implement Bool at all?
Yes! It's named Bool. :)
Obviously, but then I need to include the numarray include file to make sure I get the right definition, and I do not always want to do that. See below.
I guess at the Python level it does not matter what actual C type is used to implement bool arrays as it only represents boolean values. However, at the level of C extensions I would like to deal with Bool arrays by calling existing functions written for the appropiate C type.
The easiest way now is to just declare your variables with type "Bool". The only thing I can think of which that doesn't cover is printf/scanf. Are there others?
This does not work if you want to call a routine that was not written using the numarray typedefs. For instance, I like to write my array processing routines such that I can use them in a standalone C program without linking to numarray. These routines know nothing about numarray, but as long as the layout and data types of the arrays are correct I can still use them in numarray C routines. Then you need to know of course exactly what the C data types of the numarray routines are. That is easy for most types since they are exactly defined by bit-size and sign. But this is currently not true for the Bool type.
That would be somewhat simpler if Bool is always garantueed to be either a unsigned or a signed char type.
I think perhaps we should just re-define Bool as signed char. Any other opinions?
That would solve the problem. Peter
Mensaje citado por: Peter Verveer
That would be somewhat simpler if Bool is always garantueed to be either a unsigned or a signed char type.
I think perhaps we should just re-define Bool as signed char. Any other opinions?
That would solve the problem.
I'm in the same position than Peter. I would definitively prefer a standard C type for booleans. Francesc Alted
On Tue, 2003-05-06 at 12:16, Francesc Alted wrote:
Mensaje citado por: Peter Verveer
: That would be somewhat simpler if Bool is always garantueed to be either a unsigned or a signed char type.
I think perhaps we should just re-define Bool as signed char. Any other opinions?
That would solve the problem.
I'm in the same position than Peter. I would definitively prefer a standard C type for booleans.
Francesc Alted
I re-defined Bool as signed char in CVS. Without any real expertise in Boolology <ahem>, I am unqualified to comment further. Let me know if you would like something different. Todd
------------------------------------------------------- Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara The only event dedicated to issues related to Linux enterprise solutions www.enterpriselinuxforum.com
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
-- Todd Miller jmiller@stsci.edu STSCI / ESS / SSB
participants (3)
-
Francesc Alted
-
Peter Verveer
-
Todd Miller