Skip to content

Default buffer logic in store ABC #3643

Open

Description

@d-v-b

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

But 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"))
# None

I 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?

Activity

  1. d-v-b commented on Jan 8, 2026

    @d-v-b
    ContributorAuthor

    cc @TomAugspurger who suggested this in #3638

  2. d-v-b commented on Jan 8, 2026

    @d-v-b
    ContributorAuthor

    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?

    Following up on this, there are no store methods that do anything with ndbuffers. So why do we pass an ndbuffer class to store methods via prototype: BufferPrototyp, instead of just providing a Buffer class?

  3. added theissue type on Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    design discussionDiscussion about the design of the library

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions