I need to know if there is a way to share memory for an array of bool lists:
s = Array( 'x' , range(10000000))
What do I have to write instead of x to make it an array of lists whose size is 64. Then I have to manipulate "s" in two different processes like these:
#First
for i in range(0,photoCount):
db.newDBS.insert_one({ 'photo' : s[i], 'user_id' : ids[i] })
#Second
s[photoCount].append = inPhoto
What should be the type? Any help or suggestion appreciated. Thank you!
1 Answer 1
Python Multiprocessing module allows 2 types of shared variables : Array, which is a simple 1D array of a single dtype, and Value, which is just a single value.
You can design your own shared variables using ctype, if you know your way in C : see the documentation here.
If you just need a 2D Array and you don't want to use ctype shared objects, maybe you could flatten your array in a single list and use multiprocessing.Array instead? Then just reshape when your processing is done.
Comments
Explore related questions
See similar questions with these tags.