Numeric: difference between zeros((3,)'f') and array([0.0,0.0,0.0])
Pearu Peterson
pearu at cens.ioc.ee
Tue Feb 4 12:36:30 EST 2003
On 4 Feb 2003, Marcus Stojek wrote:
> Hi,
> I have a written c extension using swig. (see typemap below). The
> python function expects a Numeric.array as input.
> (Python 2.2 Numeric 22.0 Win NT)
>
> This array is filled with result values in the c extension. ok.
>
> if I create the array with
>
> L=[0.0 for i in range(1000)]
> a=Numeric.array(L)
>
> everything works fine and a is filled with results. If I use:
>
> b=Numeric.zeros((1000,),'f')
>
> b still contains 0.0 only. iscontiguous() gives 1 for a and b.
>
> In my interpretation this means that for the first case a is passed by
> PyArray_ContiguousFromObject because $input already is
> contiguous and for the second case a contiguous copy of $input (b) is
> made. (Besides of getting no results i can watch my heap grow if
> cfunc is called repeatedly with the same input b)
>
> Can anybody explain how a and b differ?
Note that `b` contains C float numbers while `a` contains C double
numbers. `b=Numeric.zeros((1000,),'d')` would be equivalent to `a`.
Pearu
More information about the Python-list
mailing list