Skip to content

Commit 84c9780

Browse files
committed
avoid circular imports by importing lower-level routines exactly where needed
1 parent 5b0c3ac commit 84c9780

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/zarr/abc/store.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
from itertools import starmap
77
from typing import TYPE_CHECKING, Protocol, runtime_checkable
88

9-
from zarr.core.buffer.core import default_buffer_prototype
10-
from zarr.core.common import concurrent_map
11-
from zarr.core.config import config
12-
139
if TYPE_CHECKING:
1410
from collections.abc import AsyncGenerator, AsyncIterator, Iterable
1511
from types import TracebackType
@@ -438,6 +434,8 @@ async def getsize(self, key: str) -> int:
438434
# Note to implementers: this default implementation is very inefficient since
439435
# it requires reading the entire object. Many systems will have ways to get the
440436
# size of an object without reading it.
437+
from zarr.core.buffer.core import default_buffer_prototype
438+
441439
value = await self.get(key, prototype=default_buffer_prototype())
442440
if value is None:
443441
raise FileNotFoundError(key)
@@ -476,6 +474,9 @@ async def getsize_prefix(self, prefix: str) -> int:
476474
# on to getting sizes. Ideally we would overlap those two, which should
477475
# improve tail latency and might reduce memory pressure (since not all keys
478476
# would be in memory at once).
477+
from zarr.core.common import concurrent_map
478+
from zarr.core.config import config
479+
479480
keys = [(x,) async for x in self.list_prefix(prefix)]
480481
limit = config.get("async.concurrency")
481482
sizes = await concurrent_map(keys, self.getsize, limit=limit)

0 commit comments

Comments
 (0)