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
d43ec746
Commit
d43ec746
authored
Feb 14, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add minimal documentation for const memory views.
parent
7d9fa927
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
4 deletions
+36
-4
CHANGES.rst
CHANGES.rst
+9
-4
docs/src/userguide/memoryviews.rst
docs/src/userguide/memoryviews.rst
+27
-0
No files found.
CHANGES.rst
View file @
d43ec746
...
...
@@ -8,10 +8,6 @@ Cython Changelog
Features added
--------------
* When compiling with gcc, the module init function is now tuned for small
code size instead of whatever compile flags were provided externally.
(Github issue #2102)
* Cdef classes can now multiply inherit from ordinary Python classes.
(The primary base must still be a c class, possibly ``object``, and
the other bases must *not* be cdef classes.)
...
...
@@ -19,6 +15,15 @@ Features added
* Type inference is now supported for Pythran compiled NumPy expressions.
Patch by Nils Braun. (Github issue #1954)
* Read-only buffers are automatically supported for memoryviews if it can be
determined at compile time that the code does not need write access.
They can also be allowed explicitly by adding the ``const`` modifier to their
declaration. (Github issues #1605, #1869)
* When compiling with gcc, the module init function is now tuned for small
code size instead of whatever compile flags were provided externally.
(Github issue #2102)
* C file includes are moved behind the module declarations if possible, to allow
them to depend on module declarations themselves.
Patch by Jeroen Demeyer. (Github issue #1896)
...
...
docs/src/userguide/memoryviews.rst
View file @
d43ec746
...
...
@@ -227,6 +227,33 @@ 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_.
Const buffers
-------------
Since Cython 0.28, memoryviews can be declared as ``const`` to allow
read-only buffers as input::
cdef const double[:] myslice
a = np.linspace(0, 10, num=50)
a.setflags(write=False)
myslice = a
Note that this does not *require* the input to be read-only::
a = np.linspace(0, 10, num=50)
myslice = a
Writable buffers will still be accepted by ``const`` views, but read-only
buffers are not accepted for non-const, writable views.
Cython will also request a read-only view automatically if it can determine
at compile time that a writable buffer is not required. The support for
automatically distinguishing between buffer usage types, and the compile
time correctness checks for read-only views are expected to further improve
over time.
Comparison to the old buffer support
====================================
...
...
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