Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(21)

Unified Diff: Doc/library/stdtypes.rst

Issue 15944: memoryviews and ctypes
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Lib/test/test_buffer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Doc/library/stdtypes.rst Thu Aug 06 13:17:27 2015 +0300
+++ b/Doc/library/stdtypes.rst Thu Aug 06 16:47:44 2015 +0000
@@ -3561,12 +3561,15 @@
Cast a memoryview to a new format or shape. *shape* defaults to
``[byte_length//new_itemsize]``, which means that the result view
will be one-dimensional. The return value is a new memoryview, but
- the buffer itself is not copied. Supported casts are 1D -> C-contiguous
- and C-contiguous -> 1D.
-
- Both formats are restricted to single element native formats in
- :mod:`struct` syntax. One of the formats must be a byte format
- ('B', 'b' or 'c'). The byte length of the result must be the same
+ the buffer itself is not copied. Casting is only supported for
+ C-contiguous views, and only when either the old or new shape is
+ one-dimensional.
+
+ The new format is restricted to a single element native format in
+ :mod:`struct` syntax. Any C-contiguous view may be cast to a
+ one-dimensional byte view, using the 'B', 'b' or 'c' formats.
+ Otherwise, the original view must be in one of those byte formats.
+ The byte length of the result must be the same
as the original length.
Cast 1D/long to 1D/unsigned bytes::
@@ -3645,6 +3648,9 @@
.. versionadded:: 3.3
+ .. versionchanged:: 3.6
+ Original format no longer restricted when casting to a byte view.
+
There are also several readonly attributes available:
.. attribute:: obj
« no previous file with comments | « no previous file | Lib/test/test_buffer.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+