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
Kirill Smelkov
cython
Commits
0f27c211
Commit
0f27c211
authored
Oct 12, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up getbuffer code in array.pxd
parent
87eae658
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
18 deletions
+16
-18
Cython/Includes/cpython/array.pxd
Cython/Includes/cpython/array.pxd
+16
-18
No files found.
Cython/Includes/cpython/array.pxd
View file @
0f27c211
...
...
@@ -46,13 +46,13 @@
: 2012-05-02 andreasvc
: (see revision control)
"""
from
libc
cimport
stdlib
from
libc.string
cimport
strcat
,
strncat
,
\
memset
,
memchr
,
memcmp
,
memcpy
,
memmove
from
cpython.object
cimport
Py_SIZE
from
cpython.ref
cimport
PyTypeObject
,
Py_TYPE
from
cpython.exc
cimport
PyErr_BadArgument
from
cpython.mem
cimport
PyMem_Malloc
,
PyMem_Free
cdef
extern
from
*
:
# Hard-coded utility code hack.
ctypedef
class
array
.
array
[
object
arrayobject
]
...
...
@@ -82,7 +82,7 @@ cdef extern from *: # Hard-coded utility code hack.
ctypedef
class
array
.
array
[
object
arrayobject
]:
cdef
__cythonbufferdefaults__
=
{
'ndim'
:
1
,
'mode'
:
'c'
}
cdef
:
Py_ssize_t
ob_size
arraydescr
*
ob_descr
# struct arraydescr *ob_descr;
...
...
@@ -93,31 +93,29 @@ cdef extern from *: # Hard-coded utility code hack.
# requirements, and does not yet fullfill the PEP.
# In particular strided access is always provided regardless
# of flags
cdef
unsigned
rows
,
columns
,
itemsize
item_count
=
Py_SIZE
(
self
)
info
.
suboffsets
=
NULL
info
.
buf
=
self
.
data
.
as_chars
info
.
readonly
=
0
info
.
ndim
=
1
info
.
itemsize
=
itemsize
=
self
.
ob_descr
.
itemsize
# e.g. sizeof(float)
info
.
strides
=
<
Py_ssize_t
*>
\
stdlib
.
malloc
(
sizeof
(
Py_ssize_t
)
*
info
.
ndim
*
2
+
2
)
info
.
shape
=
info
.
strides
+
1
info
.
shape
[
0
]
=
Py_SIZE
(
self
)
# number of items
info
.
strides
[
0
]
=
info
.
itemsize
info
.
format
=
<
char
*>
(
info
.
strides
+
2
*
info
.
ndim
)
info
.
itemsize
=
self
.
ob_descr
.
itemsize
# e.g. sizeof(float)
info
.
len
=
info
.
itemsize
*
item_count
info
.
shape
=
<
Py_ssize_t
*>
PyMem_Malloc
(
sizeof
(
Py_ssize_t
)
+
2
)
if
not
info
.
shape
:
raise
MemoryError
()
info
.
shape
[
0
]
=
item_count
# constant regardless of resizing
info
.
strides
=
&
info
.
itemsize
info
.
format
=
<
char
*>
(
info
.
shape
+
1
)
info
.
format
[
0
]
=
self
.
ob_descr
.
typecode
info
.
format
[
1
]
=
0
info
.
obj
=
self
def
__releasebuffer__
(
array
self
,
Py_buffer
*
info
):
#if PyArray_HASFIELDS(self):
# stdlib.free(info.format)
#if sizeof(npy_intp) != sizeof(Py_ssize_t):
stdlib
.
free
(
info
.
strides
)
PyMem_Free
(
info
.
shape
)
array
newarrayobject
(
PyTypeObject
*
type
,
Py_ssize_t
size
,
arraydescr
*
descr
)
# fast resize/realloc
...
...
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