[Numpy-discussion] Bytes vs. Unicode in Python3

Francesc Alted faltet@pytables....
Wed Dec 9 04:06:36 CST 2009


A Sunday 06 December 2009 11:47:23 Francesc Alted escrigué:
> A Saturday 05 December 2009 11:16:55 Dag Sverre Seljebotn escrigué:
> > > In [19]: t = np.dtype("i4,f4")
> > >
> > > In [20]: t
> > > Out[20]: dtype([('f0', '<i4'), ('f1', '<f4')])
> > >
> > > In [21]: hash(t)
> > > Out[21]: -9041335829180134223
> > >
> > > In [22]: t.names = ('one', 'other')
> > >
> > > In [23]: t
> > > Out[23]: dtype([('one', '<i4'), ('other', '<f4')])
> > >
> > > In [24]: hash(t)
> > > Out[24]: 8637734220020415106
> > >
> > > Perhaps this should be marked as a bug?  I'm not sure about that,
> > > because the above seems quite useful.
> >
> > Well, I for one don't like this, but that's just an opinion. I think it
> > is unwise to leave object which supports hash() mutable, because it's
> > too easy to make hard to find bugs (sticking a dtype as a key in a dict
> > is rather useful in many situations). There's a certain tradition in
> > Python for leaving types immutable if possible, and dtype certainly
> > feels like it.
> 
> Yes, I think you are right and force dtype to be immutable would be the
>  best.

I've filed a ticket so that we don't loose track of this:

http://projects.scipy.org/numpy/ticket/1321

-- 
Francesc Alted


More information about the NumPy-Discussion mailing list