[Python-Dev] Hashable memoryviews
Nick Coghlan
ncoghlan at gmail.com
Sun Nov 13 02:40:43 CET 2011
More information about the Python-Dev mailing list
Sun Nov 13 02:40:43 CET 2011
- Previous message: [Python-Dev] Hashable memoryviews
- Next message: [Python-Dev] Hashable memoryviews
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, Nov 13, 2011 at 11:19 AM, Antoine Pitrou <solipsis at pitrou.net> wrote: > 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) Having a memory view be hashable if the object it references is hashable seems analogous to the way tuples are hashable if everything they reference is hashable, so +0 from me. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] Hashable memoryviews
- Next message: [Python-Dev] Hashable memoryviews
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list