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
7ea33ca3
Commit
7ea33ca3
authored
Jul 06, 2018
by
scoder
Committed by
GitHub
Jul 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2435 from gabrieldemarmiesse/test_memoryviews_7
Added tests for "typed memoryviews" part 7
parents
0366b382
60dcd089
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
18 deletions
+25
-18
docs/examples/userguide/memoryviews/memory_layout.pyx
docs/examples/userguide/memoryviews/memory_layout.pyx
+11
-0
docs/examples/userguide/memoryviews/memory_layout_2.pyx
docs/examples/userguide/memoryviews/memory_layout_2.pyx
+6
-0
docs/src/userguide/memoryviews.rst
docs/src/userguide/memoryviews.rst
+8
-18
No files found.
docs/examples/userguide/memoryviews/memory_layout.pyx
0 → 100644
View file @
7ea33ca3
from
cython
cimport
view
# direct access in both dimensions, strided in the first dimension, contiguous in the last
cdef
int
[:,
::
view
.
contiguous
]
a
# contiguous list of pointers to contiguous lists of ints
cdef
int
[::
view
.
indirect_contiguous
,
::
1
]
b
# direct or indirect in the first dimension, direct in the second dimension
# strided in both dimensions
cdef
int
[::
view
.
generic
,
:]
c
docs/examples/userguide/memoryviews/memory_layout_2.pyx
0 → 100644
View file @
7ea33ca3
from
cython
cimport
view
# VALID
cdef
int
[::
view
.
indirect
,
::
1
,
:]
a
cdef
int
[::
view
.
indirect
,
:,
::
1
]
b
cdef
int
[::
view
.
indirect_contiguous
,
::
1
,
:]
c
docs/src/userguide/memoryviews.rst
View file @
7ea33ca3
...
@@ -415,31 +415,21 @@ The flags are as follows:
...
@@ -415,31 +415,21 @@ The flags are as follows:
* contiguous - contiguous and direct
* contiguous - contiguous and direct
* indirect_contiguous - the list of pointers is contiguous
* indirect_contiguous - the list of pointers is contiguous
and they can be used like this:
:
and they can be used like this:
from cython cimport view
.. literalinclude:: ../../examples/userguide/memoryviews/memory_layout.pyx
# direct access in both dimensions, strided in the first dimension, contiguous in the last
cdef int[:, ::view.contiguous] a
# contiguous list of pointers to contiguous lists of ints
Only the first, last or the dimension following an indirect dimension may be
cdef int[::view.indirect_contiguous, ::1] b
specified contiguous:
# direct or indirect in the first dimension, direct in the second dimension
.. literalinclude:: ../../examples/userguide/memoryviews/memory_layout_2.pyx
# strided in both dimensions
cdef int[::view.generic, :] c
Only the first, last or the dimension following an indirect dimension may be
::
specified contiguous::
# INVALID
# INVALID
cdef int[::view.contiguous, ::view.indirect, :]
a
cdef int[::view.contiguous, ::view.indirect, :]
d
cdef int[::1, ::view.indirect, :]
b
cdef int[::1, ::view.indirect, :]
e
# VALID
cdef int[::view.indirect, ::1, :] a
cdef int[::view.indirect, :, ::1] b
cdef int[::view.indirect_contiguous, ::1, :]
The difference between the `contiguous` flag and the `::1` specifier is that the
The difference between the `contiguous` flag and the `::1` specifier is that the
former specifies contiguity for only one dimension, whereas the latter specifies
former specifies contiguity for only one dimension, whereas the latter specifies
...
...
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