Cool article! thanks for the nice read, I always wanted a use case for generators but I was never able to decide when to use them (some times I keep this idea) but I remember usin Generators to retrieve paginated mongo cursors from a collection with a registry over hundreds of thousand records, we had to process each record individually (at least that was what I was tasked to do), but you know expecting things to be faster than the blink of an eye.
something like this (pardon me about syntax errors or not being logic at all, the original snippet is somewhere and I do remember do further modifications to it)
and then processed each cursor on a stream for given collection, generators were my salvation because they were lazily evaluated once the previous stream finished processing the whole cursor, that also prevented my streams from clogging and losing data. I tried a similar solution without the generators, but I was losing data and my streams were hanging too
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Cool article! thanks for the nice read, I always wanted a use case for generators but I was never able to decide when to use them (some times I keep this idea) but I remember usin Generators to retrieve paginated mongo cursors from a collection with a registry over hundreds of thousand records, we had to process each record individually (at least that was what I was tasked to do), but you know expecting things to be faster than the blink of an eye.
something like this (pardon me about syntax errors or not being logic at all, the original snippet is somewhere and I do remember do further modifications to it)
and then processed each cursor on a stream for given collection, generators were my salvation because they were lazily evaluated once the previous stream finished processing the whole cursor, that also prevented my streams from clogging and losing data. I tried a similar solution without the generators, but I was losing data and my streams were hanging too