Is there a faster way in generating a dictionary with a certain default value? I basically want an equavalent of
arrays = [True] * (n+1)
but for dictionary. I currently have:
dicts = dict([(i,True) for i in range(0,n+1)])
The problem is with n = 1000000, the times I am getting with this implementation is 0.016s for the array and 0.318 for the dicts. Is there a faster way to do this for the dictionary?