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/2011-November/114461.html below:

[Python-Dev] Hashable memoryviews

[Python-Dev] Hashable memoryviews [Python-Dev] Hashable memoryviewsAntoine Pitrou solipsis at pitrou.net
Sun Nov 13 02:19:27 CET 2011
On Sat, 12 Nov 2011 17:15:08 -0800
Guido van Rossum <guido at python.org> wrote:
> Aren't memoryview objects mutable? I think that the underlying memory
> can change, so it shouldn't be hashable.

Only if the original object is itself mutable, otherwise the memoryview
is read-only.

I would propose the following algorithm:
1) try to calculate the original object's hash; if it fails, consider
   the memoryview unhashable (the buffer is probably mutable)
2) otherwise, calculate the memoryview's hash with the same algorithm
   as bytes objects (so that it's compatible with equality comparisons)

Regards

Antoine.
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