bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / may_share_memory
built-in
numpy:may_share_memory
Signature
built-in
may_share_memory ( a , b , / , max_work = 0 ) Summary
Determine if two arrays might share memory
Extended Summary
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, b: ndarrayInput arrays
max_work: int, optionalEffort to spend on solving the overlap problem. See
shares_memoryfor details. Default formay_share_memoryis to do a bounds check.
Returns
out: bool
Examples
import numpy as np np.may_share_memory(np.array([1,2]), np.array([5,8,9])) x = np.zeros([3, 4]) np.may_share_memory(x[:,0], x[:,1])✓
See also
- shares_memory
Aliases
-
numpy.may_share_memory -
numpy._core._multiarray_umath.may_share_memory