I've seen questions and answers for generating a set of numbers within one range but excluding specific numbers like here
https://stackoverflow.com/a/41643919/3259896
But I am wondering if there's any computational efficiency for selecting a number from one range, but excluding a whole sub range.
So I would want to pick a number between 0 and 200, excluding numbers 75 to 130.
The obvious solution to declare whole lists for the entire possible ranges of 0 to 75 and 130 to 200, concatenate them, and select a number from that range.
import random
allowed_values = list(range(0, 75)) + list(range(130, 200))
# can be anything in {-5, ..., 5} \ {0}:
random_value = random.choice(allowed_values)
This seems a bit wasteful time-wise and space-wise. Is there a more efficient solution due to efficiencies of excluding a whole range instead of specific numbers?