Jan-28-2018, 03:48 AM
To be honest, I can't really understand your question, what is 't' and what is 's'?
You mean, that one set should have 1000 random elements and the other set 10,000? This way then:
You mean, that one set should have 1000 random elements and the other set 10,000? This way then:
In [1]: %%timeit ...: ...: import numpy as np ...: SCALE = 1000 ...: s1 = set( (np.random.rand(1000) * SCALE).astype('int') ) ...: s2 = set( (np.random.rand(10000) * SCALE).astype('int') ) ...: s1.intersection(s2) ...: The slowest run took 748.40 times longer than the fastest. This could mean that an intermediate result is being cached. 1 loop, best of 3: 1.28 ms per loop