How to increase the performance of a search with for

0

Basically the program I did does this same procedure, but with more data. I need to increase search performance, of course this can be done with libraries if that is better. No matter how performance improves, as long as the data format stays the same.

import time
import random

numbers = []
searchs = []
search_range = 1

for i in range(0, 9999):
    numbers.append((int(random.random() * 100), int(random.random() * 100), int(random.random() * 100)))
    searchs.append((int(random.random() * 100), int(random.random() * 100), int(random.random() * 100)))

start = time.time()
for search in searchs:
    for number in numbers:
        if (search[0] > (number[0] - search_range) and search[0] < (number[0] + search_range) and
            search[1] > (number[1] - search_range) and search[1] < (number[1] + search_range) and
            search[2] > (number[2] - search_range) and search[2] < (number[2] + search_range)):
            print(number)
            break

print('Time: %.2f' % (time.time() - start))

Note: Remembering that only what I want is search performance, the rest of the program was just an example.

    
asked by anonymous 02.02.2018 / 15:37

0 answers