vendredi 25 septembre 2020

Taking random samples from a python generator

I'm using the function for pair in itertools.combinations(bug_map.keys(), 2): to generate all pairs of elements in my db. The problem is that the amount of element is around 6.6 K and so the number of combinations is 21.7 M. Also, combinations are emitted in lexicographic sort order.

Supposing that I would take random pairs from the generator without "yielding" all of them (just a subset of n dimension), what can I do?




Aucun commentaire:

Enregistrer un commentaire