Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
dbf56c2e
Commit
dbf56c2e
authored
Sep 01, 2012
by
Stefan Krah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #15814: Document planned restrictions for memoryview hashes in 3.3.1.
parent
49dc1d40
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
15 deletions
+7
-15
Doc/library/stdtypes.rst
Doc/library/stdtypes.rst
+7
-15
No files found.
Doc/library/stdtypes.rst
View file @
dbf56c2e
...
...
@@ -2376,8 +2376,8 @@ copying.
>>> data
bytearray(b'z1spam')
Memoryviews of hashable (read-only) types
are also hashable. The hash
is defined as ``hash(m) == hash(m.tobytes())``::
Memoryviews of hashable (read-only) types
with formats 'B', 'b' or 'c'
are also hashable. The hash
is defined as ``hash(m) == hash(m.tobytes())``::
>>> v = memoryview(b'abcefg')
>>> hash(v) == hash(b'abcefg')
...
...
@@ -2387,21 +2387,13 @@ copying.
>>> hash(v[::-2]) == hash(b'abcefg'[::-2])
True
Hashing of multi-dimensional objects is supported::
>>> buf = bytes(list(range(12)))
>>> x = memoryview(buf)
>>> y = x.cast('B', shape=[2,2,3])
>>> x.tolist()
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
>>> y.tolist()
[[[0, 1, 2], [3, 4, 5]], [[6, 7, 8], [9, 10, 11]]]
>>> hash(x) == hash(y) == hash(y.tobytes())
True
.. versionchanged:: 3.3
Memoryview objects are now hashable.
Memoryview objects
with formats 'B', 'b' or 'c'
are now hashable.
.. note::
Hashing of memoryviews with formats other than 'B', 'b' or 'c' is
possible in version 3.3.0, but will raise an error in 3.3.1 in order
to be compatible with the new memoryview equality definition.
:class:`memoryview` has several methods:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment