use sklearn's xrange
use Parallel for n_jobs = 1