[PYTHON MATRIX-SIG] Two questions

Paul F. Dubois dubois1@llnl.gov
Wed, 29 May 96 11:00:21 PDT


We decided to make it harder to compute with floats rather than hard to
behave normally. (:->. Seriously, the design tradeoff was to either force the 
person who wanted to be sure they stayed float to be more careful or to
screw up automatic type conversion. Since double does not cost a great deal
more CPU than single, the issue is just those arrays for which space is a
major issue.
In your example you need to make the scalar you are adding to 'a' to also be
a float array of size 1.

Yes, your example leaks. Just return the new array without Py_BuildValue,
since the latter adds a reference. You already have one from the creation call.
>
> Hi all,
>
>I'm using Numerical Python 0.36 since a few weeks and I'm really
>impressed...
>Two questions, however:
>
> 1- I'd like to compute with floats, instead of doubles, to save
>    storage (for now, I frequently run out of my 100Mo swap space).
>   1.1 : this is probably a bug: 
>        >>> from Numeric import *
>        >>> a = ones(10,Float(32))
>        >>> a.typecode()
>        'd'
>   1.2 : the above bug comes from an implicit conversion :
>        >>> a = zeros(10,Float(32))
>	>>> a.typecode()
>        'f'
>        >>> b = a + 1
>	>>> b.typecode()
>        'd'
>The consequence is that's currently impossible to compute with
>floats... ? I don't exactly remember the conclusions from the
>previous discussions about conversion rules, but the current behaviour
>is uncomfortable, especially with *big* arrays. Did I miss something ?
>
>
> 2- The second question :
>The following code builds and returns an array from C:
> 
>  PyArrayObject arr = (PyArrayObject *)PyArray_FromDims( 
>	nbdims,dims, PyArray_FLOAT );
>  if (!arr) { 
>	...
>  }
>  do something with arr->data
>
>  return Py_BuildValue("O", arr );
>
>Is this right ? (This seems to leak).
>
>
>Thanks for your attention
>Emmanuel
>
>-- 
>Emmanuel Viennet: <viennet@ura1507.univ-paris13.fr>
>LIPN - Institut Galilee - Universite Paris-Nord       
>93430 Villetaneuse -  France
>
>=================
>MATRIX-SIG  - SIG on Matrix Math for Python
>
>send messages to: matrix-sig@python.org
>administrivia to: matrix-sig-request@python.org
>=================
>
>
Paul F. Dubois
Lawrence Livermore National Laboratory


=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================