On Sep 5, 11:18 am, [EMAIL PROTECTED] wrote:
> Helmut Jarausch:
>
> > I need to hash arrays of integers (from the hash module).
>
> One of the possible solutions is to hash the equivalent tuple, but it
> requires some memory (your sequence must not be tuples already):

why can't it be tuple already? Doesn't matter:

>>> from numpy import arange
>>> a=arange(5)
>>> a
array([0, 1, 2, 3, 4])
>>> hash(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: unhashable type
>>> b=tuple(a)
>>> b
(0, 1, 2, 3, 4)
>>> c=tuple(b)
>>> c
(0, 1, 2, 3, 4)
>>> hash(c)
1286958229

you can discard the tuple, so the memory requirement is transient.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to