Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
7dc1360b
Commit
7dc1360b
authored
Nov 21, 2019
by
mitch
Committed by
Stefan Behnel
Feb 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated documentation to mention 'const' for read-only buffers
parent
c2e6c693
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
docs/src/tutorial/strings.rst
docs/src/tutorial/strings.rst
+9
-8
docs/src/userguide/memoryviews.rst
docs/src/userguide/memoryviews.rst
+3
-0
No files found.
docs/src/tutorial/strings.rst
View file @
7dc1360b
...
...
@@ -220,14 +220,15 @@ object. This can simply be done as follows:
.. literalinclude:: ../../examples/tutorial/string/return_memview.pyx
If the byte input is actually encoded text, and the further processing
should happen at the Unicode level, then the right thing to do is to
decode the input straight away. This is almost only a problem in Python
2.x, where Python code expects that it can pass a byte string (:obj:`str`)
with encoded text into a text API. Since this usually happens in more
than one place in the module's API, a helper function is almost always the
way to go, since it allows for easy adaptation of the input normalisation
process later.
For read-only buffers, like :obj:`bytes`, the memoryview item type should
be declared as ``const`` (see :ref:`readonly_views`). If the byte input is
actually encoded text, and the further processing should happen at the
Unicode level, then the right thing to do is to decode the input straight
away. This is almost only a problem in Python 2.x, where Python code
expects that it can pass a byte string (:obj:`str`) with encoded text into
a text API. Since this usually happens in more than one place in the
module's API, a helper function is almost always the way to go, since it
allows for easy adaptation of the input normalisation process later.
This kind of input normalisation function will commonly look similar to
the following:
...
...
docs/src/userguide/memoryviews.rst
View file @
7dc1360b
...
...
@@ -155,6 +155,9 @@ As for NumPy, new axes can be introduced by indexing an array with ``None`` ::
One may mix new axis indexing with all other forms of indexing and slicing.
See also an example_.
.. _readonly_views:
Read-only views
---------------
...
...
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