[ Web Proxy ]
URL:
Viewing: https://numpy.org/doc/stable/reference/generated/../c-api/../generated/numpy.may_share_memory.html [Back]  [Original]

numpy.may_share_memory — NumPy v2.5 Manual
Back to top
Search the docs ...:

numpy.may_share_memory#

numpy.may_share_memory(a, b, /, max_work=0)#

Determine if two arrays might share memory

A return of True does not necessarily mean that the two arrays share any element. It just means that they might.

Only the memory bounds of a and b are checked by default.

Parameters:
a, bndarray

Input arrays

max_workint, optional

Effort to spend on solving the overlap problem. See shares_memory for details. Default for may_share_memory is to do a bounds check.

Returns:
outbool

See also

shares_memory

Examples

Try it in your browser!
>>> import numpy as np
>>> np.may_share_memory(np.array([1,2]), np.array([5,8,9]))
False
>>> x = np.zeros([3, 4])
>>> np.may_share_memory(x[:,0], x[:,1])
True

Web Proxy Viewer  |  New URL  |  Original Page