[Numpy-discussion] Bytes vs. Unicode in Python3

David Cournapeau cournape@gmail....
Fri Dec 4 10:57:14 CST 2009


On Sat, Dec 5, 2009 at 1:31 AM, Bruce Southey <bsouthey@gmail.com> wrote:
> On 12/04/2009 10:12 AM, David Cournapeau wrote:
>> On Fri, Dec 4, 2009 at 9:23 PM, Francesc Alted<faltet@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


More information about the NumPy-Discussion mailing list