Python’s xrange alternative for R OR how to loop over large dataset lazilly?

One (arguably more “proper”) way to approach this would be to write your own iterator for iterators that @BenBolker suggested (pdf on writing extensions is here). Lacking something more formal, here is a poor-man’s iterator, similar to expand.grid but manually-advancing. (Note: this will suffice given that the computation on each iteration is “more expensive” than … Read more