[Numpy-discussion] how to work with numpy.int8 in c
Tue Mar 2 13:44:00 CST 2010
On Mon, Mar 1, 2010 at 1:44 AM, David Cournapeau <firstname.lastname@example.org> wrote:
> On Mon, Mar 1, 2010 at 1:35 PM, James Bergstra
> <email@example.com> wrote:
>> Could someone point me to documentation (or even numpy src) that shows
>> how to allocate a numpy.int8 in C, or check to see if a PyObject is a
> In numpy, the type is described in the dtype type object, so you
> should create the appropriate PyArray_Descr when creating an array.
> The exact procedure depends on how you create the array, but a simple
> way to create arrays is PyArray_SimpleNew, where you don't need to
> create your own dtype, and just pass the correponding typenum (C
> enum), something like PyArray_SimpleNew(nd, dims, NPY_INT8).
> If you need to create from a function which only takes PyArray_Descr,
> you can easily create a simple descriptor object from the enum using
> You can see examples in numpy/core/src/multiarray/ctors.c
Maybe I'm missing something... but I don't think I want to create an array.
In : import numpy
In : type(numpy.int8())
Out: <type 'numpy.int8'>
In : isinstance(numpy.int8(), numpy.ndarray)
I want to create one of those numpy.int8 guys. Can I do it with
More information about the NumPy-Discussion