PYTHON-1752 bulk_write should be able to accept a generator#2262
Closed
sleepyStick wants to merge 13 commits intomongodb:masterfrom
Closed
PYTHON-1752 bulk_write should be able to accept a generator#2262sleepyStick wants to merge 13 commits intomongodb:masterfrom
sleepyStick wants to merge 13 commits intomongodb:masterfrom
Conversation
ShaneHarvey
reviewed
Apr 3, 2025
| """ | ||
| run = None | ||
| for idx, (op_type, operation) in enumerate(self.ops): | ||
| for idx, request in enumerate(requests): |
Member
There was a problem hiding this comment.
I think the goal of this ticket is to avoid inflating the whole generator upfront and only iterate requests as they are needed at the encoding step. For example:
coll.bulk_write((InsertOne({'x': 'large'*1024*1024}) for _ in range(1_000_000))If we inflate all at once like we do here, then that code will need to allocate all 1 million documents at once.
There was a problem hiding this comment.
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
pymongo/synchronous/bulk.py:745
- [nitpick] Consider renaming the 'generator' parameter to 'requests' for clarity, since it represents the source of write operations and to align with the naming in bulk_write.
generator: Generator[_WriteOp[_DocumentType]],
pymongo/asynchronous/bulk.py:747
- [nitpick] Consider renaming the 'generator' parameter to 'requests' to better reflect its purpose and to maintain consistency with other bulk_write method signatures.
generator: Generator[_WriteOp[_DocumentType]],
…tryable var to bulk class to match client_bulk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Notes: