numpy.shares_memory()函数确定两个阵列是否共享内存。
用法: numpy.shares_memory(arr1, arr2, max_work = None)
参数:
arr1, arr2: [ndarray] Input arrays.
max_work: [int, optional] Effort to spend on solving the overlap problem.
返回: [bool] Checking if two arrays share memory.
代码1:
# Python program explaining
# numpy.shares_memory() function
# importing numpy as geek
import numpy as geek
arr1 = geek.array([1, 2, 3, 4])
arr2 = geek.array([5, 6, 7])
gfg = geek.shares_memory(arr1, arr2)
print (gfg)
输出:
False
代码2:
# Python program explaining
# numpy.shares_memory() function
# importing numpy as geek
import numpy as geek
arr1 = geek.array([1, 2, 3, 4])
arr2 = arr1[::2]
gfg = geek.shares_memory(arr1, arr2)
print (gfg)
输出:
True
相关用法
- Python Wand function()用法及代码示例
- Python now()用法及代码示例
- Python id()用法及代码示例
- Python tell()用法及代码示例
- Python sum()用法及代码示例
- Python str()用法及代码示例
- Python cmp()用法及代码示例
- Python ord()用法及代码示例
- Python dir()用法及代码示例
- Python hex()用法及代码示例
- Python int()用法及代码示例
- Python map()用法及代码示例
- Python oct()用法及代码示例
- Python math.sin()用法及代码示例
- Python bytearray()用法及代码示例
- Python math.tan()用法及代码示例
注:本文由纯净天空筛选整理自sanjoy_62大神的英文原创作品 numpy.shares_memory() function – Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。