From 2f22a11e17ab51af5972260b4aa7d234a7076096 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Wed, 8 Apr 2026 02:32:56 -0500 Subject: [PATCH] perf: parallelize get_card_embeds calls in display_cards (#98) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #98 Replace sequential await-in-list-comprehension with asyncio.gather() so all card embed fetches run concurrently. Cuts 50 sequential DB round-trips (5 packs × 5 cards × 2 calls each) down to ~2 concurrent batches. Co-Authored-By: Claude Sonnet 4.6 --- helpers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/main.py b/helpers/main.py index 2cae635..301a340 100644 --- a/helpers/main.py +++ b/helpers/main.py @@ -339,7 +339,7 @@ async def display_cards( cards.sort(key=lambda x: x["player"]["rarity"]["value"]) logger.debug("Cards sorted successfully") - card_embeds = [await get_card_embeds(x) for x in cards] + card_embeds = list(await asyncio.gather(*[get_card_embeds(x) for x in cards])) logger.debug(f"Created {len(card_embeds)} card embeds") page_num = 0 if pack_cover is None else -1