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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
e4838d84
Commit
e4838d84
authored
Feb 15, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify doc section on const memoryviews.
parent
3469020f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
docs/src/userguide/memoryviews.rst
docs/src/userguide/memoryviews.rst
+8
-8
No files found.
docs/src/userguide/memoryviews.rst
View file @
e4838d84
...
@@ -227,27 +227,27 @@ As for NumPy, new axes can be introduced by indexing an array with ``None`` ::
...
@@ -227,27 +227,27 @@ 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.
One may mix new axis indexing with all other forms of indexing and slicing.
See also an example_.
See also an example_.
Const buffer
s
Read-only view
s
-------------
-------------
--
Since Cython 0.28,
memoryviews can be declared as ``const`` to allow
Since Cython 0.28,
the memoryview item type can be declared as ``const`` to
read-only buffers as input::
support
read-only buffers as input::
cdef const double[:] myslice
cdef const double[:] myslice
# const item type => read-only view
a = np.linspace(0, 10, num=50)
a = np.linspace(0, 10, num=50)
a.setflags(write=False)
a.setflags(write=False)
myslice = a
myslice = a
Note that this does not *require* the input to be read-only::
Note that this does not *require* the input
buffer
to be read-only::
a = np.linspace(0, 10, num=50)
a = np.linspace(0, 10, num=50)
myslice = a
myslice = a
# read-only view of a writable buffer
Writable buffers are still accepted by ``const`` views, but read-only
Writable buffers are still accepted by ``const`` views, but read-only
buffers are not accepted for non-const, writable views::
buffers are not accepted for non-const, writable views::
cdef double[:] myslice # a normal read
-
write memory view
cdef double[:] myslice # a normal read
/
write memory view
a = np.linspace(0, 10, num=50)
a = np.linspace(0, 10, num=50)
a.setflags(write=False)
a.setflags(write=False)
...
...
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