PyDocs

Nav

Concurrent Execution

ShareableList

  • ShareableList(sequence=None, *, name=None)
Pattern for a mutable list-like object shareable via a shared
memory block.  It differs from the built-in list type in that these
lists can not change their overall length (i.e. no append, insert,
etc.)

Because values are packed into a memoryview as bytes, the struct
packing format for any storable value must require no more than 8
characters to describe its format.
Members of ShareableList

c

count
L.count(value) -> integer -- return number of occurrences of value.

f

format
The struct packing format used by all currently stored items.

i

index
Raises ValueError if the value is not present.

s

shm
The SharedMemory instance where the values are stored.
1 Example
>>> from multiprocessing import shared_memory
>>> nul_bug_demo = shared_memory.ShareableList(['?\x00', b'\x03\x02\x01\x00\x00\x00'])
>>> nul_bug_demo[0]
'?'
>>> nul_bug_demo[1]
b'\x03\x02\x01'
>>> nul_bug_demo.shm.unlink()
>>> padded = shared_memory.ShareableList(['?\x00\x07', b'\x03\x02\x01\x00\x00\x00\x07'])
>>> padded[0][:-1]
'?\x00'
>>> padded[1][:-1]
b'\x03\x02\x01\x00\x00\x00'
>>> padded.shm.unlink()
from the Python docs
See Also
No see-alsos for multiprocessing.shared_memory/ShareableList
0 Notes
No notes for ShareableList