Commit graph

7 commits

Author SHA1 Message Date
dmahan93
4a21ed0891 Enhance ScoredData model and API documentation
- Added optional fields: advantages, messages, and images to the ScoredData model.
- Updated API responses to include these new fields when no data is available.
- Revised README.md to reflect changes in the API structure and response format.
2025-06-02 17:28:25 -05:00
Shannon Sands
a7dfd377da moving env to clean branch 2025-05-10 07:44:29 +10:00
Shannon Sands
4f6a0014bc precommit 2025-05-10 07:30:57 +10:00
dmahan93
c1ba77ec26
Merge pull request #7 from misrasaurabh1/codeflash/optimize-grab_exact_from_heterogeneous_queue-ma3pegzo
️ Speed up function `grab_exact_from_heterogeneous_queue` by 1,680%
2025-05-09 12:18:56 -05:00
dmahan93
301cc03b9d
require register-env to wait until batch is hit 2025-05-08 11:28:38 -05:00
codeflash-ai[bot]
837ef6295d
️ Speed up function grab_exact_from_heterogeneous_queue by 1,680%
Here’s a highly optimized version of your code for both **runtime** and **memory**, based on the profile hot spots.

- **Avoid repeated summing** for checking lengths in a growing list — we keep a running sum.
- **Avoid repeatedly copying lists/dicts** by using lists of indices and marking to remove in one pass, and using set operations for fast membership checks.
- **Avoid creating lots of small dicts** and list extensions inside loops.
- **Combine related generator expressions** so costly operations are only done once.
- **Group similar linear scans** into one to minimize number of loops over `queue`.
- Use **pre-allocated lists and sets** where it saves time.

Here's the rewritten function (all comments preserved except where the code logic was changed).



**Key optimizations:**
- Only a *single pass* over queue for setup.
- No repeated `.append(dict)`; pass only indices around until the end.
- Use `.clear()` for lists inside dict to avoid reallocations.
- Use lists of lengths for O(1) access everywhere.
- Maintain a running sum for batch size check, not repeated `sum`.

This should **dramatically cut runtime**, especially at the hot spots from your line profiler output. If you need even more speed and the queue is huge/long-lived, consider reworking the data structure for the queue itself (`deque`, heap, etc.), but for code-level optimization this is near optimal for this algorithm!
2025-04-30 08:58:23 +00:00
Dakota Nous
621d00dd80 first commit 2025-04-29 12:10:10 -07:00