k = do_subsample
sql = "SELECT _rowid_ FROM %s ORDER BY _rowid_ ASC" % (qt,)
cursor = bdb.sql_execute(sql)
rowids = [row[0] for row in cursor]
n = len(rowids)
seed = struct.pack("<QQQQ", 0, 0, k, n)
uniform = weakprng.weakprng(seed).weakrandom_uniform
randomly_permute(rowids, uniform)
After Change
uniform = weakprng.weakprng(seed).weakrandom_uniform
samples = [None] * k
for i, row in enumerate(cursor):
r = uniform(i + 1)
if r < k:
samples[r] = row
cursor = [s for s in samples if s is not None]
else: