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
21d383ad
Commit
21d383ad
authored
Nov 10, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor optimization of previous change.
parent
fd7e2651
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
Cython/Includes/numpy.pxd
Cython/Includes/numpy.pxd
+10
-6
No files found.
Cython/Includes/numpy.pxd
View file @
21d383ad
...
...
@@ -52,7 +52,9 @@ cdef extern from "numpy/arrayobject.h":
# requirements, and does not yet fullfill the PEP.
# In particular strided access is always provided regardless
# of flags
cdef
int
copy_shape
cdef
int
copy_shape
,
i
,
ndim
ndim
=
PyArray_NDIM
(
self
)
if
sizeof
(
npy_intp
)
!=
sizeof
(
Py_ssize_t
):
copy_shape
=
1
else
:
...
...
@@ -67,11 +69,13 @@ cdef extern from "numpy/arrayobject.h":
raise
ValueError
(
"ndarray is not Fortran contiguous"
)
info
.
buf
=
PyArray_DATA
(
self
)
info
.
ndim
=
PyArray_NDIM
(
self
)
info
.
ndim
=
ndim
if
copy_shape
:
info
.
strides
=
<
Py_ssize_t
*>
stdlib
.
malloc
(
sizeof
(
Py_ssize_t
)
*
info
.
ndim
)
info
.
shape
=
<
Py_ssize_t
*>
stdlib
.
malloc
(
sizeof
(
Py_ssize_t
)
*
info
.
ndim
)
for
i
in
range
(
info
.
ndim
):
# Allocate new buffer for strides and shape info. This is allocated
# as one block, strides first.
info
.
strides
=
<
Py_ssize_t
*>
stdlib
.
malloc
(
sizeof
(
Py_ssize_t
)
*
ndim
*
2
)
info
.
shape
=
info
.
strides
+
ndim
for
i
in
range
(
ndim
):
info
.
strides
[
i
]
=
PyArray_STRIDES
(
self
)[
i
]
info
.
shape
[
i
]
=
PyArray_DIMS
(
self
)[
i
]
else
:
...
...
@@ -185,8 +189,8 @@ cdef extern from "numpy/arrayobject.h":
# obj is set to NULL in those case)
stdlib
.
free
(
info
.
format
)
if
sizeof
(
npy_intp
)
!=
sizeof
(
Py_ssize_t
):
stdlib
.
free
(
info
.
shape
)
stdlib
.
free
(
info
.
strides
)
# info.shape was stored after info.strides in the same block
cdef
void
*
PyArray_DATA
(
ndarray
arr
)
...
...
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