-
-
Notifications
You must be signed in to change notification settings - Fork 373
Description
the store abc get method requires specifying a buffer prototype. That leads to code like this:
from zarr.core.buffer.core import default_buffer_prototype
from zarr.storage import MemoryStore
from zarr.core.sync import sync
x = MemoryStore()
sync(x.get("foo", prototype=default_buffer_prototype))
# NoneBut the memorystore implementation of get overrides the base signature to allow prototype to be None which is also the default value, in which case the default buffer prototype is used. This makes the code simpler:
from zarr.storage import MemoryStore
from zarr.core.sync import sync
x = MemoryStore()
sync(x.get("foo"))
# NoneI propose that we push this "prototype can be None" logic to the store ABC, and define a method on the ABC like _get_default_buffer_prototype(self, ...) -> BufferPrototype, which can default to the exact logic MemoryStore (and LocalStore) currently uses.
I also note that the prototype parameter is annotated as a BufferPrototype which is effectively a tuple of Buffer and NDBuffer classes, but the stores methods never return NDBuffers, so shouldn't we just take Buffer classes here?