diff --git a/src/asynchrony/various.py b/src/asynchrony/various.py index e5f89d2..7969cd2 100644 --- a/src/asynchrony/various.py +++ b/src/asynchrony/various.py @@ -18,13 +18,9 @@ async def retry_with_backoff(func, max_retries=3): async def fetch_user(user_id: int) -> dict: """Simulates fetching a user from a database""" - await asyncio.sleep(0.0001) + await asyncio.sleep(0.001) return {"id": user_id, "name": f"User{user_id}"} async def fetch_all_users(user_ids: list[int]) -> list[dict]: - users = [] - for user_id in user_ids: - user = await fetch_user(user_id) - users.append(user) - return users + return await asyncio.gather(*(fetch_user(user_id) for user_id in user_ids))