summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/numeric.py3
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c29
2 files changed, 31 insertions, 1 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index a187d7c5b..bb2f3d28d 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -40,7 +40,7 @@ __all__ = ['newaxis', 'ndarray', 'flatiter', 'nditer', 'nested_iters', 'ufunc',
'Inf', 'inf', 'infty', 'Infinity',
'nan', 'NaN', 'False_', 'True_', 'bitwise_not',
'CLIP', 'RAISE', 'WRAP', 'MAXDIMS', 'BUFSIZE', 'ALLOW_THREADS',
- 'ComplexWarning']
+ 'ComplexWarning', 'may_share_memory']
if sys.version_info[0] < 3:
__all__.extend(['getbuffer', 'newbuffer'])
@@ -252,6 +252,7 @@ fromstring = multiarray.fromstring
fromiter = multiarray.fromiter
fromfile = multiarray.fromfile
frombuffer = multiarray.frombuffer
+may_share_memory = multiarray.may_share_memory
if sys.version_info[0] < 3:
newbuffer = multiarray.newbuffer
getbuffer = multiarray.getbuffer
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index a1c9e7c30..7332a26d0 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -3544,6 +3544,32 @@ PyDataMem_RENEW(void *ptr, size_t size)
return (char *)result;
}
+static PyObject *
+array_may_share_memory(PyObject *NPY_UNUSED(ignored), PyObject *args)
+{
+ PyArrayObject * self = NULL;
+ PyArrayObject * other = NULL;
+ int overlap;
+
+ if (!PyArg_ParseTuple(args, "O&O&", PyArray_Converter, &self,
+ PyArray_Converter, &other)) {
+ return NULL;
+ }
+
+ overlap = arrays_overlap(self, other);
+ Py_XDECREF(self);
+ Py_XDECREF(other);
+
+ if (overlap) {
+ Py_RETURN_TRUE;
+ }
+ else {
+ Py_RETURN_FALSE;
+ }
+}
+
+
+
static struct PyMethodDef array_module_methods[] = {
{"_get_ndarray_c_version",
(PyCFunction)array__get_ndarray_c_version,
@@ -3644,6 +3670,9 @@ static struct PyMethodDef array_module_methods[] = {
{"result_type",
(PyCFunction)array_result_type,
METH_VARARGS, NULL},
+ {"may_share_memory",
+ (PyCFunction)array_may_share_memory,
+ METH_VARARGS, NULL},
/* Datetime-related functions */
{"datetime_data",
(PyCFunction)array_datetime_data,