Python (large) lists and unique combinations: smartest way to do them -


i read page on here: get unique combinations of elements python list

the solution approved works...

... but works "small" lists (100 elements, example).

i have "big" list of strings (1 million of elements) , infamous "memoryerror" exception.

what best way unique combos on large lists?

thanks in advance

per inspectorg4dget's comment , linked answer, if large number of values in initial list duplicated, filter them out through set first, find combos.

from itertools import combinations  elements = [gigantic list]  uniques = tuple(set(elements)) combos = [','.join(str(thing) thing in combo) combo in combinations(uniques, 2)] 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -