Exemple #1
0
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())
Exemple #2
0
 def randint(a, b):
     gen = Random(rand_counter.next())
     return int((gen.random() * (b - a)) + a)
Exemple #3
0
 def f(x, y):
     rnd = Random(x)
     rnd.init_by_array([x, y])
     rnd.jumpahead(y)
     return rnd.genrand32(), rnd.random()
Exemple #4
0
 def f(x, y):
     rnd = Random(x)
     rnd.init_by_array([x, y])
     rnd.jumpahead(intmask(y))
     return rnd.genrand32(), rnd.random()