[pypy-commit] pypy cpyext-ext: move PyArray_CopyInto into python
mattip
pypy.commits at gmail.com
Thu Dec 17 15:13:04 EST 2015
Author: mattip <matti.picus at gmail.com>
Branch: cpyext-ext
Changeset: r81370:fc642900fdf9
Date: 2015-12-17 21:55 +0200
http://bitbucket.org/pypy/pypy/changeset/fc642900fdf9/
Log: move PyArray_CopyInto into python
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -1074,8 +1074,7 @@
import pypy.module.cpyext.ndarrayobject
global GLOBALS, SYMBOLS_C, separate_module_files
GLOBALS["PyArray_Type#"]= ('PyTypeObject*', "space.gettypeobject(W_NDimArray.typedef)")
- SYMBOLS_C += ['PyArray_Type', '_PyArray_FILLWBYTE', '_PyArray_ZEROS',
- '_PyArray_CopyInto']
+ SYMBOLS_C += ['PyArray_Type', '_PyArray_FILLWBYTE', '_PyArray_ZEROS']
separate_module_files.append(source_dir / "ndarrayobject.c")
return use_micronumpy
diff --git a/pypy/module/cpyext/include/numpy/arrayobject.h b/pypy/module/cpyext/include/numpy/arrayobject.h
--- a/pypy/module/cpyext/include/numpy/arrayobject.h
+++ b/pypy/module/cpyext/include/numpy/arrayobject.h
@@ -197,11 +197,9 @@
PyAPI_FUNC(void) _PyArray_FILLWBYTE(PyObject* obj, int val);
PyAPI_FUNC(PyObject *) _PyArray_ZEROS(int nd, npy_intp* dims, int type_num, int fortran);
-PyAPI_FUNC(int) _PyArray_CopyInto(PyArrayObject* dest, PyArrayObject* src);
#define PyArray_FILLWBYTE _PyArray_FILLWBYTE
#define PyArray_ZEROS _PyArray_ZEROS
-#define PyArray_CopyInto _PyArray_CopyInto
#define PyArray_Resize(self, newshape, refcheck, fortran) (NULL)
diff --git a/pypy/module/cpyext/ndarrayobject.py b/pypy/module/cpyext/ndarrayobject.py
--- a/pypy/module/cpyext/ndarrayobject.py
+++ b/pypy/module/cpyext/ndarrayobject.py
@@ -170,13 +170,13 @@
return w_array
@cpython_api([Py_ssize_t], PyObject)
-def _PyArray_DescrFromType(space, typenum):
+def PyArray_DescrFromType(space, typenum):
try:
dtype = get_dtype_cache(space).dtypes_by_num[typenum]
return dtype
except KeyError:
raise OperationError(space.w_ValueError, space.wrap(
- '_PyArray_DescrFromType called with invalid dtype %d' % typenum))
+ 'PyArray_DescrFromType called with invalid dtype %d' % typenum))
@cpython_api([PyObject, Py_ssize_t, Py_ssize_t, Py_ssize_t], PyObject)
def _PyArray_FromObject(space, w_obj, typenum, min_depth, max_depth):
@@ -250,6 +250,16 @@
return simple_new(space, nd, dims, typenum,
order=order, owning=owning, w_subtype=w_subtype)
+ at cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
+def PyArray_CopyInto(space, w_dest, w_src):
+ assert isinstance(w_dest, W_NDimArray)
+ assert isinstance(w_src, W_NDimArray)
+ space.appexec([w_dest, w_src], """(dest, src):
+ dest[:] = src
+ """ )
+ return 0
+
+
gufunctype = lltype.Ptr(ufuncs.GenericUfunc)
# XXX single rffi.CArrayPtr(gufunctype) does not work, this does, is there
# a problem with casting function pointers?
diff --git a/pypy/module/cpyext/src/ndarrayobject.c b/pypy/module/cpyext/src/ndarrayobject.c
--- a/pypy/module/cpyext/src/ndarrayobject.c
+++ b/pypy/module/cpyext/src/ndarrayobject.c
@@ -16,10 +16,3 @@
return arr;
}
-int
-_PyArray_CopyInto(PyArrayObject* dest, PyArrayObject* src)
-{
- memcpy(PyArray_DATA(dest), PyArray_DATA(src), PyArray_NBYTES(dest));
- return 0;
-}
-
More information about the pypy-commit
mailing list