[Numpy-discussion] numpy, Py_ssize_t, cython and 64 bits python 2.4

Charles R Harris charlesr.harris@gmail....
Sun Nov 9 17:59:34 CST 2008

On Sun, Nov 9, 2008 at 4:37 PM, Dag Sverre Seljebotn <
dagss@student.matnat.uio.no> wrote:

> Charles R Harris wrote:
> > But mixing python types and numpy types is not a good idea, they exist
> > separately and apply to different software. This may be different for
> > the buffer interface, which is likely to cross the boundary, but that is
> > an argument for being very careful on how the buffer interface is dealt
> > with in cython.
> >
> Which is why an exception is thrown in this mismatch circumstance -- if
> we weren't careful, the cast would happen, which would be very bad.

I think the arguments should be copied and explicitly cast. It's nasty, but
crossing boundaries always is. There are some old compatibility functions in
numpy that do the same thing.

Isn't this a bit conservative? It looks to me like long and double would be
good bets for a lot of these. The boolean type, '?', is also missing.

187 ctypedef signed int npy_byte
188 ctypedef signed int npy_short
189 ctypedef signed int npy_int
190 ctypedef signed int npy_long
191 ctypedef signed int npy_longlong
193 ctypedef unsigned int npy_ubyte
194 ctypedef unsigned int npy_ushort
195 ctypedef unsigned int npy_uint
196 ctypedef unsigned int npy_ulong
197 ctypedef unsigned int npy_ulonglong
199 ctypedef float npy_float
200 ctypedef float npy_double
201 ctypedef float npy_longdouble
203 ctypedef signed int npy_int8
204 ctypedef signed int npy_int16
205 ctypedef signed int npy_int32
206 ctypedef signed int npy_int64
207 ctypedef signed int npy_int96
208 ctypedef signed int npy_int128
210 ctypedef unsigned int npy_uint8
211 ctypedef unsigned int npy_uint16
212 ctypedef unsigned int npy_uint32
213 ctypedef unsigned int npy_uint64
214 ctypedef unsigned int npy_uint96
215 ctypedef unsigned int npy_uint128
217 ctypedef float npy_float32
218 ctypedef float npy_float64
219 ctypedef float npy_float80
220 ctypedef float npy_float96
221 ctypedef float npy_float128

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20081109/1b0a8155/attachment.html 

More information about the Numpy-discussion mailing list