grain.sources.SharedMemoryDataSource

grain.sources.SharedMemoryDataSource#

class grain.sources.SharedMemoryDataSource(elements=None, *, name=None)#

Simple in-memory data source for sequences that is sharable among multiple processes.

Note

This constrains storable values to only the int, float, bool, str (less than 10M bytes each), bytes (less than 10M bytes each), and None built-in data types. It also notably differs from the built-in list type in that these lists can not change their overall length (i.e. no append, insert, etc.)

Parameters:
  • elements (Sequence[Any] | None)

  • name (str | None)

__init__(elements=None, *, name=None)#

Creates a new InMemoryDataSource object.

Parameters:
  • elements (Sequence[Any] | None) – The elements for the sharable list.

  • name (str | None) – The name of the datasource.

Methods

__init__([elements, name])

Creates a new InMemoryDataSource object.

close()

count(value)

index(value)

Raises ValueError if the value is not present.

unlink()

Attributes

format

The struct packing format used by all currently stored items.