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
4a9efd8d
Commit
4a9efd8d
authored
Sep 06, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nogil transpose
parent
71064916
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
10 deletions
+13
-10
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-6
Cython/Utility/MemoryView.pyx
Cython/Utility/MemoryView.pyx
+3
-4
tests/run/numpy_memoryview.pyx
tests/run/numpy_memoryview.pyx
+7
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
4a9efd8d
...
@@ -4196,10 +4196,6 @@ class AttributeNode(ExprNode):
...
@@ -4196,10 +4196,6 @@ class AttributeNode(ExprNode):
elif
self
.
type
.
is_memoryviewslice
:
elif
self
.
type
.
is_memoryviewslice
:
if
self
.
is_memslice_transpose
:
if
self
.
is_memslice_transpose
:
# transpose the slice
# transpose the slice
if
self
.
in_nogil_context
:
error
(
self
.
pos
,
"Cannot transpose slice in nogil mode"
)
return
for
access
,
packing
in
self
.
type
.
axes
:
for
access
,
packing
in
self
.
type
.
axes
:
if
access
==
'ptr'
:
if
access
==
'ptr'
:
error
(
self
.
pos
,
"Transposing not supported for slices "
error
(
self
.
pos
,
"Transposing not supported for slices "
...
@@ -4207,7 +4203,7 @@ class AttributeNode(ExprNode):
...
@@ -4207,7 +4203,7 @@ class AttributeNode(ExprNode):
return
return
code
.
putln
(
"%s = %s;"
%
(
self
.
result
(),
self
.
obj
.
result
()))
code
.
putln
(
"%s = %s;"
%
(
self
.
result
(),
self
.
obj
.
result
()))
if
self
.
obj
.
is_name
:
if
self
.
obj
.
is_name
or
self
.
obj
.
is_attribute
and
self
.
obj
.
is_memslice_transpose
:
code
.
put_incref_memoryviewslice
(
self
.
result
(),
have_gil
=
True
)
code
.
put_incref_memoryviewslice
(
self
.
result
(),
have_gil
=
True
)
T
=
"__pyx_memslice_transpose(&%s) == 0"
T
=
"__pyx_memslice_transpose(&%s) == 0"
...
@@ -4259,7 +4255,8 @@ class AttributeNode(ExprNode):
...
@@ -4259,7 +4255,8 @@ class AttributeNode(ExprNode):
elif
self
.
type
.
is_memoryviewslice
:
elif
self
.
type
.
is_memoryviewslice
:
import
MemoryView
import
MemoryView
MemoryView
.
put_assign_to_memviewslice
(
MemoryView
.
put_assign_to_memviewslice
(
select_code
,
rhs
.
result
(),
self
.
type
,
code
)
select_code
,
rhs
.
result
(),
self
.
type
,
code
,
incref_rhs
=
rhs
.
is_name
)
if
not
self
.
type
.
is_memoryviewslice
:
if
not
self
.
type
.
is_memoryviewslice
:
code
.
putln
(
code
.
putln
(
...
...
Cython/Utility/MemoryView.pyx
View file @
4a9efd8d
...
@@ -723,7 +723,7 @@ cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
...
@@ -723,7 +723,7 @@ cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
### Transposing a memoryviewslice
### Transposing a memoryviewslice
#
#
@
cname
(
'__pyx_memslice_transpose'
)
@
cname
(
'__pyx_memslice_transpose'
)
cdef
int
transpose_memslice
({{
memviewslice_name
}}
*
memslice
)
except
0
:
cdef
int
transpose_memslice
({{
memviewslice_name
}}
*
memslice
)
nogil
except
0
:
cdef
int
ndim
=
memslice
.
memview
.
view
.
ndim
cdef
int
ndim
=
memslice
.
memview
.
view
.
ndim
cdef
Py_ssize_t
*
shape
=
memslice
.
shape
cdef
Py_ssize_t
*
shape
=
memslice
.
shape
...
@@ -737,9 +737,8 @@ cdef int transpose_memslice({{memviewslice_name}} *memslice) except 0:
...
@@ -737,9 +737,8 @@ cdef int transpose_memslice({{memviewslice_name}} *memslice) except 0:
shape
[
i
],
shape
[
j
]
=
shape
[
j
],
shape
[
i
]
shape
[
i
],
shape
[
j
]
=
shape
[
j
],
shape
[
i
]
if
memslice
.
suboffsets
[
i
]
>=
0
or
memslice
.
suboffsets
[
j
]
>=
0
:
if
memslice
.
suboffsets
[
i
]
>=
0
or
memslice
.
suboffsets
[
j
]
>=
0
:
dim
=
i
if
memslice
.
suboffsets
[
i
]
>=
0
else
j
with
gil
:
raise
ValueError
(
"Cannot transpose view with indirect dimension "
raise
ValueError
(
"Cannot transpose memoryview with indirect dimensions"
)
"(axis %d)"
%
dim
)
return
1
return
1
...
...
tests/run/numpy_memoryview.pyx
View file @
4a9efd8d
...
@@ -163,6 +163,13 @@ def test_transpose():
...
@@ -163,6 +163,13 @@ def test_transpose():
print
a_obj
.
T
.
shape
print
a_obj
.
T
.
shape
print
numpy_obj
.
T
.
shape
print
numpy_obj
.
T
.
shape
cdef
dtype_t
[:,
:]
c
with
nogil
:
c
=
a
.
T
.
T
assert
(
<
object
>
a
).
shape
==
(
<
object
>
c
).
shape
assert
(
<
object
>
a
).
strides
==
(
<
object
>
c
).
strides
print
a
[
3
,
2
],
a
.
T
[
2
,
3
],
a_obj
[
3
,
2
],
a_obj
.
T
[
2
,
3
],
numpy_obj
[
3
,
2
],
numpy_obj
.
T
[
2
,
3
]
print
a
[
3
,
2
],
a
.
T
[
2
,
3
],
a_obj
[
3
,
2
],
a_obj
.
T
[
2
,
3
],
numpy_obj
[
3
,
2
],
numpy_obj
.
T
[
2
,
3
]
def
test_coerce_to_numpy
():
def
test_coerce_to_numpy
():
...
...
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