this is a match of strings. Since the sizes are small to med, the operation run fast, but when those size increase, and maybe you place the match into a loop...things become quite frustrating..! ..especially when you manage with strings in the list
out = random.sample(range(0, 3000000, 5), 10)
g = random.sample(range(0, 20000, 5), 10)
p = [tmp.append(lu) for lu in g if not lu in out]
I've fount this proposition for C using-tr1regex-search-to-match-a-big-list-of-strings I'm going to verify
- Is there faster alternative code that select the elements in g which doesn't belong to out ?
- if not, is there any method, library or let the match run on GPU to faster this match ?
thks
CodePudding user response:
You can use sets
set(g) - set(out)
I tried on this
out = random.sample(range(0, 100000000, 5), 10000000)
g = random.sample(range(0, 100000000, 5), 10000000)
Generating the data took 34s. The set operation took only 1.5s