[Numpy-discussion] Who uses matrix?

Sasha ndarray at mac.com
Wed May 10 11:47:03 EDT 2006


On 5/10/06, Christopher Barker <Chris.Barker at noaa.gov> wrote:
> ...
> Is there even a direct way to construct a numpy scalar?
>

Yes,

>>> type(int_(0))
<type 'int32scalar'>
>>> type(float_(0))
<type 'float64scalar'>

RTFM :-)


> > Actually I thought that Sasha's position was that both scalars and
> > *rank-0* [aka shape=()] arrays were useful in different circumstances
> > and that we shouldn't completely anihilate rank-0 arrays in favor of
> > scalars.
>
> What is the difference? except that rank-o arrays are mutable, and I do
> think a mutable scalar is a good thing to have. Why not make numpy
> scalars mutable, and then would there be a difference?

Mutable objects cannot have value based hash, which practically means
they cannot be used as keys in python dictionaries.  This may change
in python 3.0, but meanwhile mutable scalars are not an option.




More information about the NumPy-Discussion mailing list