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
4171c1c0
Commit
4171c1c0
authored
Jul 06, 2018
by
scoder
Committed by
GitHub
Jul 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2434 from gabrieldemarmiesse/test_memoryviews_6
Added tests for "typed memoryviews" part 6
parents
e4260c0a
96d5dbc3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
docs/examples/userguide/memoryviews/np_flag_const.pyx
docs/examples/userguide/memoryviews/np_flag_const.pyx
+7
-0
docs/src/userguide/memoryviews.rst
docs/src/userguide/memoryviews.rst
+2
-6
No files found.
docs/examples/userguide/memoryviews/np_flag_const.pyx
0 → 100644
View file @
4171c1c0
import
numpy
as
np
cdef
const
double
[:]
myslice
# const item type => read-only view
a
=
np
.
linspace
(
0
,
10
,
num
=
50
)
a
.
setflags
(
write
=
False
)
myslice
=
a
docs/src/userguide/memoryviews.rst
View file @
4171c1c0
...
...
@@ -161,13 +161,9 @@ Read-only views
---------------
Since Cython 0.28, the memoryview item type can be declared as ``const`` to
support read-only buffers as input:
:
support read-only buffers as input:
cdef const double[:] myslice # const item type => read-only view
a = np.linspace(0, 10, num=50)
a.setflags(write=False)
myslice = a
.. literalinclude:: ../../examples/userguide/memoryviews/np_flag_const.pyx
Using a non-const memoryview with a binary Python string produces a runtime error.
You can solve this issue with a ``const`` memoryview:
...
...
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