def __init__(self, seed):
if not seed:
seed = "%.1f" % time.time()
if hasattr(seed, "encode"):
seed = seed.encode('ascii')
# A note on hashfunctions.
# We don't need cryptographic quality, so we won't use hashlib -
# that'd be way to slow. The zlib module contains two hash
# functions. Adler32 is fast, but not very uniform for short
# strings. Crc32 is slower, but has better bit distribution.
# So, we use crc32 whenever the hash is converted into an
# exportable number, but we use adler32 when we're producing
# intermediate values.
self.seed = zlib.adler32(seed)
self.text_seed = seed
# Default, typically overridden
self.size = 1024 + 786j
评论列表
文章目录