There are use cases where a generator is more convenient than passing a list of bulk write operations, for example when performing a large number of operation where creating the list would balloon memory usage.
bulk_write should be able to accept a generator without inflating the entire thing to a list. This would also allow insert_many to support generators without inflating as well which is requested in PYTHON-1517.
Some open questions:
- What should be the behavior of unordered bulk_write where the generator flips flops between request types (Insert, Update, Insert, etc...)? I think it would be a performance regression to send each operation individually but sorting the operations from the generator without ballooning memory usage will be tricky.
- is depended on by
-
PYTHON-1517 insert_many should work with arbitrarily long iterables
- Blocked
-
MOTOR-314 Allow BULK operations to accept generators
- Blocked