From: Peter V. <ve...@em...> - 2003-05-06 12:51:50
|
Hi, In the numarray source code Bool is defined as a typedef to char. Does th= e=20 Bool array type correspond to the Int8, or the UInt8 type? If I recall=20 correctly, the char type may be signed or unsigned. Can I make any=20 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=20 implement bool arrays as it only represents boolean values. However, at t= he=20 level of C extensions I would like to deal with Bool arrays by calling=20 existing functions written for the appropiate C type. That would be somew= hat=20 simpler if Bool is always garantueed to be either a unsigned or a signed = char=20 type.=20 Cheers, Peter. --=20 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: Pet...@em... |
From: Todd M. <jm...@st...> - 2003-05-06 15:48:17
|
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 |
From: Peter V. <ve...@em...> - 2003-05-06 16:17:03
|
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 s= ure I=20 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 u= sed > > to implement bool arrays as it only represents boolean values. Howeve= r, > > 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= =2E > Are there others? This does not work if you want to call a routine that was not written usi= ng=20 the numarray typedefs. For instance, I like to write my array processing=20 routines such that I can use them in a standalone C program without linki= ng=20 to numarray. These routines know nothing about numarray, but as long as t= he=20 layout and data types of the arrays are correct I can still use them in=20 numarray C routines. Then you need to know of course exactly what the C d= ata=20 types of the numarray routines are. That is easy for most types since the= y=20 are exactly defined by bit-size and sign. But this is currently not true = for=20 the Bool type. > >That would be somewhat > >simpler if Bool is always garantueed to be either a unsigned or a sign= ed > > char type. > > I think perhaps we should just re-define Bool as signed char. Any othe= r > opinions? That would solve the problem. Peter |
From: Francesc A. <fa...@op...> - 2003-05-06 16:41:52
|
Mensaje citado por: Peter Verveer <ve...@em...>: > > >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 |
From: Todd M. <jm...@st...> - 2003-05-06 21:20:41
|
On Tue, 2003-05-06 at 12:16, Francesc Alted wrote: > Mensaje citado por: Peter Verveer <ve...@em...>: > > > >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 > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion -- Todd Miller jm...@st... STSCI / ESS / SSB |