Commit 016762d1 authored by mitch's avatar mitch Committed by Stefan Behnel

updated documentation to mention 'const' for read-only buffers

parent f875f4c2
......@@ -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:
......
......@@ -153,6 +153,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
---------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment