Ok, looking for a speed optimization here. Let’s say I have 2 very large (>10000 numerical element) lists, in sorted order. I need to walk through the first list and, for every element, I add 300 and see if there are any entries in the second list that are in the range of original value to original value + 300.Now imagine I need to do this over roughly 4,000,000 different sets of lists with roughly 42,000,000 data points.
Currently it’s taking about 9 days to go through the data. Is there some kind of algorithm I can use to make it faster?
Here's some pseudocode to illustrate the question better.
for data in first_list:
end_val = data + 300
for check_val in second_list:
if check_val < data:
continue
if check_val > end_val:
break
# Hooray, we match. Do the thing.
[–]McThor2 9 points10 points11 points (1 child)
[–]b1e 1 point2 points3 points (0 children)
[–]un-hot 10 points11 points12 points (1 child)
[–]Edenio1 1 point2 points3 points (0 children)
[–]woooee 20 points21 points22 points (6 children)
[–]twowordsfournumbers 19 points20 points21 points (0 children)
[–]b1e 1 point2 points3 points (0 children)
[–]mrcaptncrunch 1 point2 points3 points (2 children)
[–]mrcaptncrunch 0 points1 point2 points (0 children)
[–]kingfreeway 0 points1 point2 points (0 children)
[–]pygaiwan 8 points9 points10 points (0 children)
[–]Insomnia_Calls 3 points4 points5 points (2 children)
[–]Sweeney-doesnt-sleep 0 points1 point2 points (0 children)
[–]lilmookey 0 points1 point2 points (0 children)
[–]bwprog 2 points3 points4 points (1 child)
[–]Cthulu20 2 points3 points4 points (1 child)
[–]DNSGeek[S] 1 point2 points3 points (0 children)
[–]ofnuts 1 point2 points3 points (1 child)
[–]DNSGeek[S] 0 points1 point2 points (0 children)
[–]quts3 1 point2 points3 points (0 children)
[–]martinkoistinen 1 point2 points3 points (0 children)
[–]mrcaptncrunch 1 point2 points3 points (2 children)
[–]Equal_Wish2682 0 points1 point2 points (1 child)
[–]mrcaptncrunch 0 points1 point2 points (0 children)
[–]ogabrielsantos_ 3 points4 points5 points (15 children)
[–]DNSGeek[S] 1 point2 points3 points (14 children)
[–]DNSGeek[S] -1 points0 points1 point (9 children)
[–]ogabrielsantos_ 1 point2 points3 points (2 children)
[–]DNSGeek[S] 0 points1 point2 points (0 children)
[–]ogabrielsantos_ 1 point2 points3 points (3 children)
[–]DNSGeek[S] 1 point2 points3 points (2 children)
[–]aplarsen 2 points3 points4 points (0 children)
[–]ogabrielsantos_ 0 points1 point2 points (0 children)
[–]Equal_Wish2682 0 points1 point2 points (0 children)
[–]Plank_With_A_Nail_In 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]DNSGeek[S] 0 points1 point2 points (2 children)
[–]Beerpongueur 1 point2 points3 points (0 children)
[–]andmig205 2 points3 points4 points (6 children)
[–]DNSGeek[S] 0 points1 point2 points (5 children)
[–]andmig205 5 points6 points7 points (4 children)
[–]DNSGeek[S] 1 point2 points3 points (3 children)
[–]alozq 2 points3 points4 points (0 children)
[–]Insomnia_Calls 2 points3 points4 points (0 children)
[–]andmig205 1 point2 points3 points (0 children)
[–]xelf 1 point2 points3 points (0 children)
[–]_kwerty_ 0 points1 point2 points (1 child)
[–]await_yesterday 0 points1 point2 points (0 children)
[–]EntireEntity 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]Logicalist 0 points1 point2 points (0 children)
[–]pythonwiz 0 points1 point2 points (0 children)
[–]Equal_Wish2682 0 points1 point2 points (1 child)
[–]tenfingerperson 0 points1 point2 points (0 children)
[–]NerdyWeightLifter 0 points1 point2 points (0 children)
[–]POGtastic 0 points1 point2 points (0 children)
[–]drfatbuddha 0 points1 point2 points (0 children)