A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-November/122528.html below:

[Python-Dev] [Python-checkins] cpython (3.3): Issue #15814: Use hash function that is compatible with the equality

[Python-Dev] [Python-checkins] cpython (3.3): Issue #15814: Use hash function that is compatible with the equalityNick Coghlan ncoghlan at gmail.com
Sat Nov 3 10:38:55 CET 2012
On Sat, Nov 3, 2012 at 3:07 AM, stefan.krah <python-checkins at python.org> wrote:
> +        # equality-hash invariant
> +        x = ndarray(list(range(12)), shape=[12], format='B')
> +        a = memoryview(nd)
> +
> +        y = ndarray(list(range(12)), shape=[12], format='b')
> +        b = memoryview(nd)
> +
> +        z = ndarray(list(bytes(chr(x), 'latin-1') for x in range(12)),
> +                    shape=[12], format='c')
> +        c = memoryview(nd)
> +
> +        if (a == b):
> +            self.assertEqual(hash(a), hash(b))
> +
> +        if (a == c):
> +            self.assertEqual(hash(a), hash(c))
> +
> +        if (b == c):
> +            self.assertEqual(hash(b), hash(c))

These checks could do with a comment explaining why the if statements
are needed (I'm assuming something to do with memory order).

Cheers,
Nick.


-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4