diff options
author | Pauli Virtanen <pav@iki.fi> | 2015-11-12 20:15:37 +0200 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2015-11-12 20:19:47 +0200 |
commit | 8efc87ec599c0b3eac4e63bea6eda9023d8ed96d (patch) | |
tree | b9f51647e66537760e63c5e662155eba9b6cde3e /numpy/add_newdocs.py | |
parent | 4be9ce7bea3321af3c9896da98c751f03459fa38 (diff) | |
download | numpy-8efc87ec599c0b3eac4e63bea6eda9023d8ed96d.tar.gz |
ENH: reimplement may_share_memory in C to improve its performance
Diffstat (limited to 'numpy/add_newdocs.py')
-rw-r--r-- | numpy/add_newdocs.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index b00e229c3..c14036089 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3826,6 +3826,45 @@ add_newdoc('numpy.core.multiarray', 'shares_memory', """) +add_newdoc('numpy.core.multiarray', 'may_share_memory', + """ + may_share_memory(a, b, max_work=None) + + 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, b : ndarray + Input arrays + max_work : int, 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 + ------- + out : bool + + See Also + -------- + shares_memory + + Examples + -------- + >>> 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 + + """) + + add_newdoc('numpy.core.multiarray', 'ndarray', ('newbyteorder', """ arr.newbyteorder(new_order='S') |