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
5658d1f1
Commit
5658d1f1
authored
Aug 03, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed dead numpy-specific hack
parent
cd6fb6ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
58 deletions
+1
-58
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+0
-57
Cython/Includes/numpy.pxd
Cython/Includes/numpy.pxd
+1
-1
No files found.
Cython/Compiler/Buffer.py
View file @
5658d1f1
...
@@ -490,14 +490,6 @@ def use_py2_buffer_functions(env):
...
@@ -490,14 +490,6 @@ def use_py2_buffer_functions(env):
find_buffer_types
(
env
)
find_buffer_types
(
env
)
# For now, hard-code numpy imported as "numpy"
# try:
# ndarrtype = env.entries[u'numpy'].as_module.entries['ndarray'].type
# types.append((ndarrtype.typeptr_cname, "numpy_getbuffer", "numpy_releasebuffer"))
# env.use_utility_code(numpy_code)
# except KeyError:
# pass
code
=
dedent
(
"""
code
=
dedent
(
"""
#if PY_VERSION_HEX < 0x02060000
#if PY_VERSION_HEX < 0x02060000
static int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
static int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
...
@@ -630,52 +622,3 @@ static void __Pyx_RaiseBufferFallbackError(void) {
...
@@ -630,52 +622,3 @@ static void __Pyx_RaiseBufferFallbackError(void) {
"""
]
"""
]
numpy_code
=
[
"""
static int numpy_getbuffer(PyObject *obj, Py_buffer *view, int flags);
static void numpy_releasebuffer(PyObject *obj, Py_buffer *view);
"""
,
"""
static int numpy_getbuffer(PyObject *obj, Py_buffer *view, int flags) {
/* This function is always called after a type-check; safe to cast */
PyArrayObject *arr = (PyArrayObject*)obj;
PyArray_Descr *type = (PyArray_Descr*)arr->descr;
int typenum = PyArray_TYPE(obj);
if (!PyTypeNum_ISNUMBER(typenum)) {
PyErr_Format(PyExc_TypeError, "Only numeric NumPy types currently supported.");
return -1;
}
/*
NumPy format codes doesn't completely match buffer codes;
seems safest to retranslate.
01234567890123456789012345*/
const char* base_codes = "?bBhHiIlLqQfdgfdgO";
char* format = (char*)malloc(4);
char* fp = format;
*fp++ = type->byteorder;
if (PyTypeNum_ISCOMPLEX(typenum)) *fp++ = 'Z';
*fp++ = base_codes[typenum];
*fp = 0;
view->buf = arr->data;
view->readonly = !PyArray_ISWRITEABLE(obj);
view->ndim = PyArray_NDIM(arr);
view->strides = PyArray_STRIDES(arr);
view->shape = PyArray_DIMS(arr);
view->suboffsets = NULL;
view->format = format;
view->itemsize = type->elsize;
view->internal = 0;
return 0;
}
static void numpy_releasebuffer(PyObject *obj, Py_buffer *view) {
free((char*)view->format);
view->format = NULL;
}
"""
]
Cython/Includes/numpy.pxd
View file @
5658d1f1
...
@@ -92,4 +92,4 @@ cdef extern from "numpy/arrayobject.h":
...
@@ -92,4 +92,4 @@ cdef extern from "numpy/arrayobject.h":
ctypedef
float
npy_float128
ctypedef
float
npy_float128
ctypedef
npy_int64
T
int64
ctypedef
npy_int64
int64
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