python/nondist/sandbox/parrotbench b0.py, 1.5, 1.6 out0, 1.4, 1.5

Update of /cvsroot/python/python/nondist/sandbox/parrotbench In directory sc8-pr-cvs1:/tmp/cvs-serv26057 Modified Files: b0.py out0 Log Message: Another game with pi(): track local assignments through a special dict. Index: b0.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/parrotbench/b0.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** b0.py 31 Dec 2003 02:04:20 -0000 1.5 --- b0.py 31 Dec 2003 06:59:41 -0000 1.6 *************** *** 252,255 **** --- 252,256 ---- class Function(object): + makeLocals = dict def __init__(self, name, args, body, globals): self.name = name *************** *** 259,263 **** def __call__(self, *args): check(len(args), len(self.args)) ! locals = dict(zip(self.args, args)) try: eval(self.body, self.globals, locals) --- 260,264 ---- def __call__(self, *args): check(len(args), len(self.args)) ! locals = self.makeLocals(zip(self.args, args)) try: eval(self.body, self.globals, locals) *************** *** 268,272 **** def __call__(self, *args): check(len(args), len(self.args)) ! locals = dict(zip(self.args, args)) try: for value in geneval(self.body, self.globals, locals): --- 269,273 ---- def __call__(self, *args): check(len(args), len(self.args)) ! locals = self.makeLocals(zip(self.args, args)) try: for value in geneval(self.body, self.globals, locals): *************** *** 905,909 **** --- 906,924 ---- print "".join(map(str, digits)) out2 = output.getvalue() + checkoutput(0) + + class TrackingDict(dict): + def __setitem__(self, *args): + writeln("%s = %.50r" % args) + super(TrackingDict, self).__setitem__(*args) + Function.makeLocals = TrackingDict + g = env['pi']() + digits = [] + for i in range(100): + digits.append(g.next()) + checkoutput(902386495) + Function.makeLocals = dict if __name__ == '__main__': main() + Index: out0 =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/parrotbench/out0,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** out0 31 Dec 2003 02:04:20 -0000 1.4 --- out0 31 Dec 2003 06:59:41 -0000 1.5 *************** *** 9175,9176 **** --- 9175,10756 ---- 3141592653 3141592653 + k = 2 + a = 4 + b = 1 + a1 = 12 + b1 = 4 + p = 4 + q = 5 [...1553 lines suppressed...] + d = 6L + d1 = 8L + p = 17161 + q = 263 + k = 132 + a = 44251238236192885942548145627920559612834490019477 + b = 53634950897741092356584376185938131188127119065994 + a1 = 13513199258755166498247119721333722230685517166948 + b1 = 17027474947792072675248882917835637732116154588448 + d = 8L + d1 = 7L + p = 17424 + q = 265 + k = 133 + a = 13513199258755166498247119721333722230685517166948 + b = 17027474947792072675248882917835637732116154588448 + a1 = 43520313785975439666984456155743242218256902033408 + b1 = 54468162456071400521620801438902299968327078885447 + d = 7L + d1 = 7L
participants (1)
-
gvanrossumļ¼ users.sourceforge.net