I am working with a huge 2d dataset and need a range query for every point, returning the neighbours within a range as a set I already have tested using an index with KD Tree form sk learn, but the problem is, it returns the index as a list and the converting to a set takes too long. Is there a data structure, which returns the points from a range query as a set and not as a list?
The result is not natively a list.
Get the source code of the k-d-tree, and modify so it directly writes to a set, instead of a list.
But I highly doubt this will solve your actual problem. Converting a small list to a set should barely be a performance issue... but well, you are using python. A traditional python set() will be a lot lot lot slower than an numpy array. But don't blame the data structure for not using a slow set.