MCPcopy Create free account
hub / github.com/numpy/numpy / array_shares_memory_impl

Function array_shares_memory_impl

numpy/core/src/multiarray/multiarraymodule.c:4324–4438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4322
4323
4324static PyObject *
4325array_shares_memory_impl(PyObject *args, PyObject *kwds, Py_ssize_t default_max_work,
4326 int raise_exceptions)
4327{
4328 PyObject * self_obj = NULL;
4329 PyObject * other_obj = NULL;
4330 PyArrayObject * self = NULL;
4331 PyArrayObject * other = NULL;
4332 PyObject *max_work_obj = NULL;
4333 static char *kwlist[] = {"self", "other", "max_work", NULL};
4334
4335 mem_overlap_t result;
4336 Py_ssize_t max_work;
4337 NPY_BEGIN_THREADS_DEF;
4338
4339 max_work = default_max_work;
4340
4341 if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|O:shares_memory_impl", kwlist,
4342 &self_obj, &other_obj, &max_work_obj)) {
4343 return NULL;
4344 }
4345
4346 if (PyArray_Check(self_obj)) {
4347 self = (PyArrayObject*)self_obj;
4348 Py_INCREF(self);
4349 }
4350 else {
4351 /* Use FromAny to enable checking overlap for objects exposing array
4352 interfaces etc. */
4353 self = (PyArrayObject*)PyArray_FROM_O(self_obj);
4354 if (self == NULL) {
4355 goto fail;
4356 }
4357 }
4358
4359 if (PyArray_Check(other_obj)) {
4360 other = (PyArrayObject*)other_obj;
4361 Py_INCREF(other);
4362 }
4363 else {
4364 other = (PyArrayObject*)PyArray_FROM_O(other_obj);
4365 if (other == NULL) {
4366 goto fail;
4367 }
4368 }
4369
4370 if (max_work_obj == NULL || max_work_obj == Py_None) {
4371 /* noop */
4372 }
4373 else if (PyLong_Check(max_work_obj)) {
4374 max_work = PyLong_AsSsize_t(max_work_obj);
4375 if (PyErr_Occurred()) {
4376 goto fail;
4377 }
4378 }
4379 else {
4380 PyErr_SetString(PyExc_ValueError, "max_work must be an integer");
4381 goto fail;

Callers 2

array_shares_memoryFunction · 0.85
array_may_share_memoryFunction · 0.85

Calls 2

solve_may_share_memoryFunction · 0.85
npy_cache_importFunction · 0.85

Tested by

no test coverage detected