Thanks for the tip,
indeed the following code works just fine with a pymongo trunk
from pymongo.connection import Connection
import itertools
conn = Connection("localhost", 27017)
db = conn['test']
col = db['db']
gen = ({'test_%s' % i: i} for i in range(0,100))
while True:
if not col.insert(itertools.islice(gen, 10)):
break
So, I'm happy, but probably it make sense to provide chunk_size to API
and let API deal with iterable objects appropriately.
In this case it will eliminate while loop and be as simple as
col.insert(gen, chunk_size=10)
On Oct 20, 11:42 am, Michael Dirolf <
m...@10gen.com> wrote:
> Also you should feel free to open a feature request for the chunk_size
> parameter on jira if it's something you'd like to see. I'd just like
> to think about it a bit more / get some more input from other users
> before committing to add it.
>