On 12/04/2009 10:57 AM, David Cournapeau wrote: > On Sat, Dec 5, 2009 at 1:31 AM, Bruce Southey<bsout...@gmail.com> wrote: > >> On 12/04/2009 10:12 AM, David Cournapeau wrote: >> >>> On Fri, Dec 4, 2009 at 9:23 PM, Francesc Alted<fal...@pytables.org> >>> wrote: >>> >>> >>>> A Thursday 03 December 2009 14:56:16 Dag Sverre Seljebotn escrigué: >>>> >>>> >>>>> Pauli Virtanen wrote: >>>>> >>>>> >>>>>> Thu, 03 Dec 2009 14:03:13 +0100, Dag Sverre Seljebotn wrote: >>>>>> [clip] >>>>>> >>>>>> >>>>>> >>>>>>> Great! Are you storing the format string in the dtype types as well? (So >>>>>>> that no release is needed and acquisitions are cheap...) >>>>>>> >>>>>>> >>>>>> I regenerate it on each buffer acquisition. It's simple low-level C code, >>>>>> and I suspect it will always be fast enough. Of course, we could *cache* >>>>>> the result in the dtype. (If dtypes are immutable, which I don't remember >>>>>> right now.) >>>>>> >>>>>> >>>>> We discussed this at SciPy 09 -- basically, they are not necesarrily >>>>> immutable in implementation, but anywhere they are not that is a bug and >>>>> no code should depend on their mutability, so we are free to assume so. >>>>> >>>>> >>>> Mmh, the only case that I'm aware about dtype *mutability* is changing the >>>> names of compound types: >>>> >>>> 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. >>>> >>>> >>> Hm, that's strange - I get the same hash in both cases, but I thought >>> I took into account names when I implemented the hashing protocol for >>> dtype. Which version of numpy on which os are you seeing this ? >>> >>> David >>> _______________________________________________ >>> NumPy-Discussion mailing list >>> NumPy-Discussion@scipy.org >>> http://mail.scipy.org/mailman/listinfo/numpy-discussion >>> >>> >> Hi, >> On the same linux 64-bit Fedora 11, I get the same hash with Python2.4 >> and numpy 1.3 but different hashes for Python2.6 and numpy 1.4. >> > Could you check the behavior of 1.4.0 on 2.4 ? The code doing hashing > for dtypes has not changed since 1.3.0, so normally only the python > should have an influence. > > David > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > These are different with Python 2.4 and numpy 1.4. Curiously I got different hash values with Python 2.5 and numpy 1.3. (For what it is worth, I get the same hash values with Python 2.3 with numpy 1.1.1).
Bruce Python 2.5.2 (r252:60911, Nov 18 2008, 09:20:42) [GCC 4.3.2 20081105 (Red Hat 4.3.2-7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> np.__version__ '1.3.0' >>> t = np.dtype("i4,f4") >>> hash(t) -9041335829180134223 >>> t.names = ('one', 'other') >>> hash(t) 8637734220020415106 [bsout...@starling python]$ /usr/local/bin/python2.4 Python 2.4.5 (#1, Oct 6 2008, 09:54:35) [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> np.__version__ '1.4.0rc1' >>> t = np.dtype("i4,f4") >>> hash(t) -9041335829180134223 >>> t.names = ('one', 'other') >>> hash(t) 8637734220020415106 Python 2.3.7 (#1, Oct 6 2008, 09:55:54) [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> np.__version__ '1.1.1' >>> t = np.dtype("i4,f4") >>> hash(t) 140552637936672 >>> t.names = ('one', 'other') >>> hash(t) 140552637936672 _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion