class W_RandomObject(W_Object): classdef = ClassDef("Random", W_Object.classdef) def __init__(self, space, klass=None): W_Object.__init__(self, space, klass) self.random = Random() @classdef.singleton_method("allocate") def method_allocate(self, space): return W_RandomObject(space, self) @classdef.method("rand") def method_rand(self, space): return space.newfloat(self.random.random())
def randint(a, b): gen = Random(rand_counter.next()) return int((gen.random() * (b - a)) + a)
def f(x, y): rnd = Random(x) rnd.init_by_array([x, y]) rnd.jumpahead(y) return rnd.genrand32(), rnd.random()
def f(x, y): rnd = Random(x) rnd.init_by_array([x, y]) rnd.jumpahead(intmask(y)) return rnd.genrand32(), rnd.random()