Message169654
Am 01.09.12 19:20, schrieb Stefan Krah:
> Disallowing non-contiguous arrays leads to very strange situations though.
I don't find that strange. That two object compare equal doesn't imply
that they both hash - only that *if* they hash, they should hash equal.
In any case, this can happen already:
py> x = memoryview(array.array('B',b'cba'))
py> b = b'cba'
py> d = {b'cba': 101}
py> b in d
True
py> x == b
True
py> x in d
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: cannot hash writable memoryview object
It can also happen with other types (although I had to look around
a bit):
py> x=set((1,2,3))
py> b=frozenset(x)
py> d={b:101}
py> b in d
True
py> x==b
True
py> x in d
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'set'
> 1) Allow bytes hashing at all: +0.5
+0
> 2) If 1) is allowed, then also non-contiguous hashing is allowed: +1
-1
> 3) Allow multi-dimensional hashing: +-0
-1 |
|
Date |
User |
Action |
Args |
2012-09-01 17:44:06 | loewis | set | recipients:
+ loewis, georg.brandl, mark.dickinson, ncoghlan, belopolsky, pitrou, scoder, vstinner, christian.heimes, Arfrever, skrah, meador.inge, Alexander.Belopolsky, python-dev, Dag.Sverre.Seljebotn |
2012-09-01 17:44:06 | loewis | link | issue15814 messages |
2012-09-01 17:44:05 | loewis | create | |
|