GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [Perf] Fix low efficient loops for large batchs by baymax591 · Pull Request #91 · TransferQueue/TransferQueue
This repository was archived by the owner on Jan 21, 2026. It is now read-only.
Conversation
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@coderabbitai review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
✅ Actions performedReview triggered.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This PR optimizes the _add_field_data function by replacing a loop-based approach with Python's built-in itemgetter for extracting field data by batch indices.
Key changes:
itemgetter for batch indexing💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
transfer_queue/storage.py (1)
776-776: Remove redundant local import.The
itemgetterimport on Line 776 is redundant since it's already imported at module scope on Line 23.Apply this diff to remove the redundant import:
- from operator import itemgetter - field_names = transfer_dict["fields"]
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
transfer_queue/storage.py (1 hunks)transfer_queue/storage.py (1)
776-786: The review comment's concern about empty sample_metas is incorrect.The code is safe as-is. StorageMetaGroups are created only when a sample is encountered, and add_sample_meta() is called immediately after creation. Groups are only stored in the storage_meta_groups dict when they have samples. Since add_sample_meta() unconditionally appends samples and local_indexes without filtering, and samples are never removed, the sample_metas list will never be empty when _add_field_data() is called. Therefore, the
indexlist derived from sample_metas will always be non-empty, anditemgetter(*index)will never fail.Likely an incorrect or invalid review comment.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| >>> result = _add_field_data(transfer_dict, meta_group, data) | ||
| >>> result["field_data"]["images"] # [img2, img0, img3] - extracted by batch_index | ||
| """ | ||
| from operator import itemgetter |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
maybe put this at the beginning of the file?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
no it's just repeated
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| merged_extra_info = {} | ||
| for chunk in data: | ||
| merged_extra_info.update(chunk.extra_info) | ||
| merged_extra_info = dict(ChainMap(*(chunk.extra_info for chunk in data))) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ChainMap merges dictionaries in reverse priority order (first in chain has highest priority), but the original code uses update() which gives later chunks higher priority. This changes the behavior when duplicate keys exist across chunks. Use {k: v for chunk in reversed(data) for k, v in chunk.extra_info.items()} or iterate forward with update to maintain original semantics.
| merged_extra_info = dict(ChainMap(*(chunk.extra_info for chunk in data))) | |
| merged_extra_info = {k: v for chunk in data for k, v in chunk.extra_info.items()} |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if len(fields) == 1: | ||
| extracted_data = {fields[0]: field_values} | ||
| else: | ||
| extracted_data = dict(zip(fields, field_values, strict=False)) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The strict=False parameter is unnecessary here since fields and field_values (from itemgetter) are guaranteed to have the same length. Consider removing it or using strict=True for additional safety.
| extracted_data = dict(zip(fields, field_values, strict=False)) | |
| extracted_data = dict(zip(fields, field_values, strict=True)) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Copilot <[email protected]>
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.