如果兩個輸入數組共享相同的內存,Numpy 的 shares_memory(~)
方法將返回 True。
參數
1. a
| array-like
第一個輸入數組。
2. b
| array-like
第二個輸入數組。
3. max_work
| int
| optional
比較內存位置時要執行的最大檢查次數:
max_work |
意義 |
---|---|
MAY_SHARE_EXACT |
檢查數組的內部內容。僅當至少有一對共享相同內存的元素時才返回 True。 |
MAY_SHARE_BOUNDS |
僅檢查數組占用的兩個邊界。 |
默認情況下,max_work=MAY_SHARE_EXACT
。
返回值
單個布爾值,其中 True 表示兩個輸入數組共享內存。
例子
a = np.array([1,2])
b = np.array([1,2])
np.shares_memory(a,b)
False
a = np.array([1,2])
b = a
np.shares_memory(a,b)
True
相關用法
- Python Wand sharpen()用法及代碼示例
- Python NumPy shape屬性用法及代碼示例
- Python Wand shade()用法及代碼示例
- Python shutil.copyfile()用法及代碼示例
- Python shutil.unregister_unpack_format()用法及代碼示例
- Python shutil.get_terminal_size()用法及代碼示例
- Python shutil.get_archive_formats()用法及代碼示例
- Python shutil.which()用法及代碼示例
- Python shutil.copytree()用法及代碼示例
- Python shutil.copymode()用法及代碼示例
- Python shutil.unpack_archive()用法及代碼示例
- Python shutil.move()用法及代碼示例
- Python shutil.copy2()用法及代碼示例
- Python shutil.unregister_archive_format()用法及代碼示例
- Python shutil.chown()用法及代碼示例
- Python shutil.copyfileobj()用法及代碼示例
- Python shlex.join用法及代碼示例
- Python shutil.copystat()用法及代碼示例
- Python shlex.quote用法及代碼示例
- Python shutil.copy()用法及代碼示例
- Python shutil.get_unpack_formats()用法及代碼示例
- Python shutil.disk_usage()用法及代碼示例
- Python sklearn.cluster.MiniBatchKMeans用法及代碼示例
- Python NumPy squeeze方法用法及代碼示例
- Python scipy.ndimage.binary_opening用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | shares_memory method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。