Friday, October 24, 2025
HomeLanguagesnumpy.shares_memory() function – Python

numpy.shares_memory() function – Python

numpy.shares_memory() function determine if two arrays share memory.

Syntax : numpy.shares_memory(arr1, arr2, max_work = None)
Parameters :
arr1, arr2 : [ndarray] Input arrays.
max_work : [int, optional] Effort to spend on solving the overlap problem.
Return : [bool] Checking if two arrays share memory.

Code #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)


Output :

False

 
Code #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)


Output :

True
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS