an element from a set

Terry Reedy tjreedy at udel.edu
Mon May 17 12:24:04 EDT 2010


On 5/17/2010 12:53 AM, Carl Banks wrote:

> Even if we were to modify the set type at the C level to support it, I
> can't think of an easy way to get a random element without selection
> bias.

At the C level, a (hashed) set is a list with empty slots. So the C 
function would have to pick random ints in the appropriate range until 
it got an index for a non-empty slot. A sequence of selections from 
equal sets would not, in general, be reproducible, since the internal 
array need not be the same.




More information about the Python-list mailing list