From santagada at codespeak.net Thu Mar 1 12:11:29 2007 From: santagada at codespeak.net (santagada at codespeak.net) Date: Thu, 1 Mar 2007 12:11:29 +0100 (CET) Subject: [pypy-svn] r39622 - in pypy/dist/pypy/lang/js: . js test/ecma Message-ID: <20070301111129.129EB10121@code0.codespeak.net> Author: santagada Date: Thu Mar 1 12:11:27 2007 New Revision: 39622 Modified: pypy/dist/pypy/lang/js/interpreter.py pypy/dist/pypy/lang/js/js/jsparse.js pypy/dist/pypy/lang/js/jsobj.py pypy/dist/pypy/lang/js/jsparser.py pypy/dist/pypy/lang/js/test/ecma/conftest.py pypy/dist/pypy/lang/js/test/ecma/shell.js Log: parser corrections, equality operator fully to the spec, py.test runner that reports why test failed, and some other misc changes Modified: pypy/dist/pypy/lang/js/interpreter.py ============================================================================== --- pypy/dist/pypy/lang/js/interpreter.py (original) +++ pypy/dist/pypy/lang/js/interpreter.py Thu Mar 1 12:11:27 2007 @@ -184,6 +184,7 @@ #Math w_math = W_Object(Class='Math') w_Global.Put('Math', w_math) + w_math.Put('__proto__', w_ObjPrototype) w_math.Put('abs', W_Builtin(absjs, Class='function')) w_math.Put('floor', W_Builtin(floorjs, Class='function')) w_math.Put('E', W_Number(math.e)) @@ -528,8 +529,49 @@ def AEC(x, y): """ Implements the Abstract Equality Comparison x == y - not following the specs yet + trying to be fully to the spec """ + type1 = x.type() + type2 = y.type() + if type1 == type2: + if type1 == "undefined" or type1 == "null": + return True + if type1 == "number": + n1 = x.ToNumber() + n2 = y.ToNumber() + nan_string = str(NaN) + if str(n1) == nan_string or str(n2) == nan_string: + return False + if n1 == n2: + return True + return False + elif type1 == "string": + return x.ToString() == y.ToString() + elif type1 == "boolean": + return x.ToBoolean() == x.ToBoolean() + return x == y + else: + #step 14 + if (type1 == "undefined" and type2 == "null") or \ + (type1 == "null" and type2 == "undefined"): + return True + if type1 == "number" and type2 == "string": + return AEC(x, W_Number(y.ToNumber())) + if type1 == "string" and type2 == "number": + return AEC(W_Number(x.ToNumber()), y) + if type1 == "boolean": + return AEC(W_Number(x.ToNumber()), y) + if type2 == "boolean": + return AEC(x, W_Number(y.ToNumber())) + if (type1 == "string" or type1 == "number") and \ + type2 == "object": + return AEC(x, y.ToPrimitive()) + if (type2 == "string" or type2 == "number") and \ + type1 == "object": + return AEC(x.ToPrimitive(), y) + return False + + objtype = x.GetValue().type() if objtype == y.GetValue().type(): if objtype == "undefined" or objtype == "null": Modified: pypy/dist/pypy/lang/js/js/jsparse.js ============================================================================== --- pypy/dist/pypy/lang/js/js/jsparse.js (original) +++ pypy/dist/pypy/lang/js/js/jsparse.js Thu Mar 1 12:11:27 2007 @@ -297,7 +297,7 @@ } if(typeof a[i].value == 'string'){ - val = a[i].value.replace(/'/g, "\\'") + val = a[i].value.replace(/\\/g, "\\\\").replace(/'/g, "\\'") } else { val = a[i].value+ ""; } Modified: pypy/dist/pypy/lang/js/jsobj.py ============================================================================== --- pypy/dist/pypy/lang/js/jsobj.py (original) +++ pypy/dist/pypy/lang/js/jsobj.py Thu Mar 1 12:11:27 2007 @@ -202,12 +202,12 @@ def internal_def_value(self, ctx, tryone, trytwo): t1 = self.Get(tryone) - if isinstance(t1, W_Object): + if isinstance(t1, W_PrimitiveObject): val = t1.Call(ctx, this=self) if isinstance(val, W_Primitive): return val t2 = self.Get(trytwo) - if isinstance(t2, W_Object): + if isinstance(t2, W_PrimitiveObject): val = t2.Call(ctx, this=self) if isinstance(val, W_Primitive): return val Modified: pypy/dist/pypy/lang/js/jsparser.py ============================================================================== --- pypy/dist/pypy/lang/js/jsparser.py (original) +++ pypy/dist/pypy/lang/js/jsparser.py Thu Mar 1 12:11:27 2007 @@ -44,12 +44,15 @@ retval = pipe.read() if not retval.startswith("{"): raise JsSyntaxError(retval) + if DEBUG: + print "received back:" + print retval return retval def unquote(t): if isinstance(t, Symbol): if t.symbol == "QUOTED_STRING": - t.additional_info = t.additional_info.strip("'").replace("\\'", "'") + t.additional_info = t.additional_info[1:-1].replace("\\'", "'").replace("\\\\", "\\") else: for i in t.children: unquote(i) @@ -68,7 +71,7 @@ return tree regexs, rules, ToAST = parse_ebnf(r""" - QUOTED_STRING: "'([^\']|\\\')*'";"""+""" + QUOTED_STRING: "'([^\\\']|\\[\\\'])*'";"""+""" IGNORE: " |\n"; data: | | ; dict: ["{"] (dictentry [","])* dictentry ["}"]; Modified: pypy/dist/pypy/lang/js/test/ecma/conftest.py ============================================================================== --- pypy/dist/pypy/lang/js/test/ecma/conftest.py (original) +++ pypy/dist/pypy/lang/js/test/ecma/conftest.py Thu Mar 1 12:11:27 2007 @@ -77,9 +77,13 @@ def run(self): ctx = JSTestFile.interp.global_context r3 = ctx.resolve_identifier('run_test').GetValue() - result = r3.Call(ctx=ctx, args=[W_Number(self.number),]).ToNumber() + w_test_array = ctx.resolve_identifier('testcases').GetValue() + w_test_number = W_Number(self.number) + result = r3.Call(ctx=ctx, args=[w_test_number,]).ToNumber() if result == 0: - raise Failed(msg="Results don't match") + w_test = w_test_array.Get(str(self.number)).GetValue() + w_reason = w_test.Get('reason').GetValue() + raise Failed(msg=w_reason.ToString()) elif result == -1: py.test.skip() Modified: pypy/dist/pypy/lang/js/test/ecma/shell.js ============================================================================== --- pypy/dist/pypy/lang/js/test/ecma/shell.js (original) +++ pypy/dist/pypy/lang/js/test/ecma/shell.js Thu Mar 1 12:11:27 2007 @@ -196,7 +196,8 @@ function run_test(tc) { // try { getTestCaseResult(testcases[tc].expect, testcases[tc].actual) - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value expected: " + +testcases[tc].expect+" but got: "+ testcases[tc].actual; return testcases[tc].passed? 1:0; // } // catch(e) { From fijal at codespeak.net Thu Mar 1 12:31:03 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 1 Mar 2007 12:31:03 +0100 (CET) Subject: [pypy-svn] r39623 - pypy/dist/pypy/translator/goal Message-ID: <20070301113103.2867610107@code0.codespeak.net> Author: fijal Date: Thu Mar 1 12:31:01 2007 New Revision: 39623 Modified: pypy/dist/pypy/translator/goal/targetpypystandalone.py Log: Kill debug a bit Modified: pypy/dist/pypy/translator/goal/targetpypystandalone.py ============================================================================== --- pypy/dist/pypy/translator/goal/targetpypystandalone.py (original) +++ pypy/dist/pypy/translator/goal/targetpypystandalone.py Thu Mar 1 12:31:01 2007 @@ -12,13 +12,16 @@ thisdir = py.magic.autopath().dirpath() app_basic_example_path = str(thisdir.join("app_basic_example.py")) +DEBUG = False + try: this_dir = os.path.dirname(__file__) except NameError: this_dir = os.path.dirname(sys.argv[0]) -def debug(msg): - os.write(2, "debug: " + msg + '\n') +def debug(msg): + if DEBUG: + os.write(2, "debug: " + msg + '\n') # __________ Entry point __________ From santagada at codespeak.net Thu Mar 1 12:40:50 2007 From: santagada at codespeak.net (santagada at codespeak.net) Date: Thu, 1 Mar 2007 12:40:50 +0100 (CET) Subject: [pypy-svn] r39624 - in pypy/dist/pypy/lang/js: . test Message-ID: <20070301114050.96B7910123@code0.codespeak.net> Author: santagada Date: Thu Mar 1 12:40:47 2007 New Revision: 39624 Modified: pypy/dist/pypy/lang/js/interpreter.py pypy/dist/pypy/lang/js/test/test_interp.py Log: strict equality Modified: pypy/dist/pypy/lang/js/interpreter.py ============================================================================== --- pypy/dist/pypy/lang/js/interpreter.py (original) +++ pypy/dist/pypy/lang/js/interpreter.py Thu Mar 1 12:40:47 2007 @@ -595,6 +595,44 @@ def decision(self, ctx, op1, op2): return W_Boolean(not AEC(op1, op2)) +def SEC(x,y): + """ + Implements the Strict Equality Comparison x === y + trying to be fully to the spec + """ + type1 = x.type() + type2 = y.type() + if type1 != type2: + return False + if type1 == "undefined" or type1 == "null": + return True + if type1 == "number": + n1 = x.ToNumber() + n2 = y.ToNumber() + nan_string = str(NaN) + if str(n1) == nan_string or str(n2) == nan_string: + return False + if n1 == n2: + return True + return False + if type1 == "string": + return x.ToString() == y.ToString() + if type1 == "boolean": + return x.ToBoolean() == x.ToBoolean() + return x == y + +class StrictEq(BinaryComparisonOp): + opcode = 'STRICT_EQ' + + def decision(self, ctx, op1, op2): + return W_Boolean(SEC(op1, op2)) + +class StrictNe(BinaryComparisonOp): + opcode = 'STRICT_NE' + + def decision(self, ctx, op1, op2): + return W_Boolean(not SEC(op1, op2)) + class In(BinaryComparisonOp): opcode = 'IN' Modified: pypy/dist/pypy/lang/js/test/test_interp.py ============================================================================== --- pypy/dist/pypy/lang/js/test/test_interp.py (original) +++ pypy/dist/pypy/lang/js/test/test_interp.py Thu Mar 1 12:40:47 2007 @@ -470,3 +470,11 @@ print(y) } """, ['5',]) + + def test_stricteq(self): + self.assert_prints(""" + print(2 === 2) + print(2 === 3) + print(2 !== 3) + print(2 !== 2) + """, ['true', 'false', 'true', 'false']) From santagada at codespeak.net Thu Mar 1 12:47:26 2007 From: santagada at codespeak.net (santagada at codespeak.net) Date: Thu, 1 Mar 2007 12:47:26 +0100 (CET) Subject: [pypy-svn] r39626 - pypy/dist/pypy/lang/js/test Message-ID: <20070301114726.BF2CE10123@code0.codespeak.net> Author: santagada Date: Thu Mar 1 12:47:23 2007 New Revision: 39626 Removed: pypy/dist/pypy/lang/js/test/autotestbase.py Modified: pypy/dist/pypy/lang/js/test/test_parser.py Log: started testing the parser again Modified: pypy/dist/pypy/lang/js/test/test_parser.py ============================================================================== --- pypy/dist/pypy/lang/js/test/test_parser.py (original) +++ pypy/dist/pypy/lang/js/test/test_parser.py Thu Mar 1 12:47:23 2007 @@ -2,30 +2,9 @@ from pypy.lang.js.test.test_interp import js_is_on_path import py -py.test.skip("FIX ME: new tests for the new parser") js_is_on_path() -def test_read_js_output(): - assert read_js_output("1+1").find("PLUS") > -1 - assert read_js_output(""" - function f(x) { - return (x); - } - """).find("RETURN") != -1 - py.test.raises(JsSyntaxError, "read_js_output(\"1+\")") - py.test.raises(JsSyntaxError, "read_js_output(\"xx xxx\")") - -def test_simple_parse(): - data = parse("1+1") - assert data['type'] == 'SCRIPT' - assert data['0']['type'] == 'SEMICOLON' - data = parse("function s(x) { return 1;}") - assert data['0']['body']['0']['value']['value'] == '1' - assert sorted(data.keys()) == ['0', 'funDecls', 'length', 'lineno', \ - 'tokenizer', 'type', 'varDecls'] - -def test_single_quote(): - "test if parser eats single quotes" - data = parse("x = '2'") - assert data['type'] == 'SCRIPT' +def test_quoting(): + read_js_output('x = "\'"') + read_js_output('x = "\\\\"') \ No newline at end of file From fijal at codespeak.net Thu Mar 1 13:46:42 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 1 Mar 2007 13:46:42 +0100 (CET) Subject: [pypy-svn] r39627 - pypy/dist/pypy/module/_ssl Message-ID: <20070301124642.F17D710117@code0.codespeak.net> Author: fijal Date: Thu Mar 1 13:46:41 2007 New Revision: 39627 Modified: pypy/dist/pypy/module/_ssl/__init__.py Log: (fijal, arigo, guido_w) - Raise import error instead of py.test.skip to be able to import socket on top of py.py Modified: pypy/dist/pypy/module/_ssl/__init__.py ============================================================================== --- pypy/dist/pypy/module/_ssl/__init__.py (original) +++ pypy/dist/pypy/module/_ssl/__init__.py Thu Mar 1 13:46:41 2007 @@ -1,6 +1,7 @@ -import py # FINISHME - more thinking needed -py.test.skip("The _ssl module is only usable when running on the exact " - "same platform from which the ssl.py was computed.") +#import py # FINISHME - more thinking needed +raise ImportError +#skip("The _ssl module is only usable when running on the exact " +# "same platform from which the ssl.py was computed.") # This module is imported by socket.py. It should *not* be used # directly. From fijal at codespeak.net Thu Mar 1 13:47:56 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 1 Mar 2007 13:47:56 +0100 (CET) Subject: [pypy-svn] r39628 - in pypy/dist/pypy/module/rsocket: . test Message-ID: <20070301124756.D1BF410117@code0.codespeak.net> Author: fijal Date: Thu Mar 1 13:47:54 2007 New Revision: 39628 Modified: pypy/dist/pypy/module/rsocket/interp_socket.py pypy/dist/pypy/module/rsocket/test/test_sock_app.py Log: (fijal, arigo, guido_w) Have errno as an argument of exception rather than a field. A bit more cpython compliant Modified: pypy/dist/pypy/module/rsocket/interp_socket.py ============================================================================== --- pypy/dist/pypy/module/rsocket/interp_socket.py (original) +++ pypy/dist/pypy/module/rsocket/interp_socket.py Thu Mar 1 13:47:54 2007 @@ -443,9 +443,11 @@ message = e.get_msg() w_module = space.getbuiltinmodule('_socket') w_exception_class = space.getattr(w_module, space.wrap(e.applevelerrcls)) - w_exception = space.call_function(w_exception_class, space.wrap(message)) if isinstance(e, SocketErrorWithErrno): - space.setattr(w_exception, space.wrap('errno'), space.wrap(e.errno)) + w_exception = space.call_function(w_exception_class, space.wrap(e.errno), + space.wrap(message)) + else: + w_exception = space.call_function(w_exception_class, space.wrap(message)) return OperationError(w_exception_class, w_exception) # ____________________________________________________________ Modified: pypy/dist/pypy/module/rsocket/test/test_sock_app.py ============================================================================== --- pypy/dist/pypy/module/rsocket/test/test_sock_app.py (original) +++ pypy/dist/pypy/module/rsocket/test/test_sock_app.py Thu Mar 1 13:47:54 2007 @@ -351,7 +351,6 @@ import socket s = socket.socket() - def test_getsetsockopt(self): import _socket as socket import struct @@ -423,3 +422,21 @@ foo = self.serv.accept() raises(error, raise_error) + +class AppTestErrno: + def setup_class(cls): + cls.space = space + + def test_errno(self): + from socket import socket, AF_INET, SOCK_STREAM, error + import errno + try: + s = socket(AF_INET, SOCK_STREAM) + import pypymagic + print pypymagic.pypy_repr(s) + s.accept() + except Exception, e: + assert len(e.args) == 2 + assert e.args[0] == errno.EINVAL + assert isinstance(e.args[1], str) + From rxe at codespeak.net Thu Mar 1 13:52:22 2007 From: rxe at codespeak.net (rxe at codespeak.net) Date: Thu, 1 Mar 2007 13:52:22 +0100 (CET) Subject: [pypy-svn] r39629 - pypy/dist/pypy/tool Message-ID: <20070301125222.8FED210117@code0.codespeak.net> Author: rxe Date: Thu Mar 1 13:52:21 2007 New Revision: 39629 Modified: pypy/dist/pypy/tool/slaveproc.py Log: make closing pipe more explicit Modified: pypy/dist/pypy/tool/slaveproc.py ============================================================================== --- pypy/dist/pypy/tool/slaveproc.py (original) +++ pypy/dist/pypy/tool/slaveproc.py Thu Mar 1 13:52:21 2007 @@ -22,6 +22,17 @@ raise EOFError return marshal.loads(s) + def forceclose(self): + try: + self.out.close() + except: + pass + + try: + self.inp.close() + except: + pass + class SlaveProcess(object): _broken = False @@ -40,6 +51,7 @@ def close(self): if not self._broken: assert self.cmd(None) == 'done' + self.exchg.forceclose() class Slave(object): From santagada at codespeak.net Thu Mar 1 14:05:56 2007 From: santagada at codespeak.net (santagada at codespeak.net) Date: Thu, 1 Mar 2007 14:05:56 +0100 (CET) Subject: [pypy-svn] r39630 - pypy/dist/pypy/lang/js/test/ecma Message-ID: <20070301130556.413AD1011A@code0.codespeak.net> Author: santagada Date: Thu Mar 1 14:05:55 2007 New Revision: 39630 Modified: pypy/dist/pypy/lang/js/test/ecma/conftest.py pypy/dist/pypy/lang/js/test/ecma/shell.js Log: tests finally run well I think Modified: pypy/dist/pypy/lang/js/test/ecma/conftest.py ============================================================================== --- pypy/dist/pypy/lang/js/test/ecma/conftest.py (original) +++ pypy/dist/pypy/lang/js/test/ecma/conftest.py Thu Mar 1 14:05:55 2007 @@ -30,12 +30,16 @@ class JSTestFile(py.test.collect.Module): def init_interp(cls): if hasattr(cls, 'interp'): - return + cls.testcases.PutValue(W_Array(), cls.interp.global_context) + cls.tc.PutValue(W_Number(0), cls.interp.global_context) + cls.interp = Interpreter() ctx = cls.interp.global_context shellpath = rootdir/'shell.js' t = load_source(shellpath.read()) t.execute(ctx) + cls.testcases = cls.interp.global_context.resolve_identifier('testcases') + cls.tc = cls.interp.global_context.resolve_identifier('tc') init_interp = classmethod(init_interp) def __init__(self, fspath, parent=None): @@ -58,18 +62,15 @@ except JsBaseExcept: raise Failed(msg="Javascript Error", excinfo=py.code.ExceptionInfo()) testcases = self.interp.global_context.resolve_identifier('testcases') + self.tc = self.interp.global_context.resolve_identifier('tc') testcount = testcases.GetValue().Get('length').GetValue().ToNumber() self.testcases = testcases - # result = [str(i) for i in range(len(values))] return range(testcount) def join(self, number): return JSTestItem(number, parent = self) - def teardown(self): - self.testcases.PutValue(W_Array(), self.interp.global_context) - -class JSTestItem(py.test.collect.Item): +class JSTestItem(py.test.collect.Item): def __init__(self, number, parent=None): super(JSTestItem, self).__init__(str(number), parent) self.number = number @@ -77,13 +78,10 @@ def run(self): ctx = JSTestFile.interp.global_context r3 = ctx.resolve_identifier('run_test').GetValue() - w_test_array = ctx.resolve_identifier('testcases').GetValue() w_test_number = W_Number(self.number) - result = r3.Call(ctx=ctx, args=[w_test_number,]).ToNumber() - if result == 0: - w_test = w_test_array.Get(str(self.number)).GetValue() - w_reason = w_test.Get('reason').GetValue() - raise Failed(msg=w_reason.ToString()) + result = r3.Call(ctx=ctx, args=[w_test_number,]).GetValue().ToString() + if result != "passed": + raise Failed(msg=result) elif result == -1: py.test.skip() Modified: pypy/dist/pypy/lang/js/test/ecma/shell.js ============================================================================== --- pypy/dist/pypy/lang/js/test/ecma/shell.js (original) +++ pypy/dist/pypy/lang/js/test/ecma/shell.js Thu Mar 1 14:05:55 2007 @@ -81,7 +81,8 @@ this.passed = getTestCaseResult( this.expect, this.actual ); if ( DEBUG ) { - print( "added " + this.description + " wich expects " + this.expect); + print( "added " + this.description + " wich expects " + this.expect + + " nr "+tc); } /* * testcases are solely maintained in the TestCase @@ -196,9 +197,9 @@ function run_test(tc) { // try { getTestCaseResult(testcases[tc].expect, testcases[tc].actual) - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value expected: " + testcases[tc].reason += ( testcases[tc].passed ) ? "passed" : "wrong value expected: " +testcases[tc].expect+" but got: "+ testcases[tc].actual; - return testcases[tc].passed? 1:0; + return testcases[tc].reason; // } // catch(e) { // return -1; From fijal at codespeak.net Thu Mar 1 15:03:09 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 1 Mar 2007 15:03:09 +0100 (CET) Subject: [pypy-svn] r39632 - pypy/dist/pypy/lib/distributed/test Message-ID: <20070301140309.CF8E410117@code0.codespeak.net> Author: fijal Date: Thu Mar 1 15:03:08 2007 New Revision: 39632 Modified: pypy/dist/pypy/lib/distributed/test/test_distributed.py Log: Fix tests a bit Modified: pypy/dist/pypy/lib/distributed/test/test_distributed.py ============================================================================== --- pypy/dist/pypy/lib/distributed/test/test_distributed.py (original) +++ pypy/dist/pypy/lib/distributed/test/test_distributed.py Thu Mar 1 15:03:08 2007 @@ -69,12 +69,36 @@ assert isinstance(fun, types.FunctionType) assert fun(2, 3) == 5 + def test_local_obj(self): + class A: + def __init__(self, x): + self.x = x + + def __len__(self): + return self.x + 8 + + from distributed.protocol import LocalProtocol + protocol = LocalProtocol() + wrap = protocol.wrap + unwrap = protocol.unwrap + item = unwrap(wrap(A(3))) + assert item.x == 3 + assert len(item) == 11 + +class AppTestDistributedTasklets(object): + def setup_class(cls): + cls.space = gettestobjspace(**{"objspace.std.withtproxy": True, + "usemodules":("_stackless",)}) + cls.w_test_env = cls.space.appexec([], """(): + from distributed import test_env + return test_env + """) + def test_remote_protocol_call(self): def f(x, y): return x + y - from distributed import test_env - protocol = test_env({"f": f}) + protocol = self.test_env({"f": f}) fun = protocol.get_remote("f") assert fun(2, 3) == 5 @@ -85,38 +109,20 @@ def f(x): return x + g() - from distributed import test_env - protocol = test_env({"f":f}) + protocol = self.test_env({"f":f}) fun = protocol.get_remote("f") assert fun(8) == 16 def test_remote_dict(self): #skip("Land of infinite recursion") - from distributed import test_env d = {'a':3} - protocol = test_env({'d':d}) + protocol = self.test_env({'d':d}) xd = protocol.get_remote('d') #assert d['a'] == xd['a'] assert d.keys() == xd.keys() assert d.values() == xd.values() assert d == xd - def test_local_obj(self): - class A: - def __init__(self, x): - self.x = x - - def __len__(self): - return self.x + 8 - - from distributed.protocol import LocalProtocol - protocol = LocalProtocol() - wrap = protocol.wrap - unwrap = protocol.unwrap - item = unwrap(wrap(A(3))) - assert item.x == 3 - assert len(item) == 11 - def test_remote_obj(self): class A: def __init__(self, x): @@ -126,8 +132,7 @@ return self.x + 8 a = A(3) - from distributed import test_env - protocol = test_env({'a':a}) + protocol = self.test_env({'a':a}) xa = protocol.get_remote("a") assert xa.x == 3 assert len(xa) == 11 @@ -146,8 +151,7 @@ a = A() - from distributed import test_env - protocol = test_env({'a':a}) + protocol = self.test_env({'a':a}) xa = protocol.get_remote('a') assert xa.__class__.__doc__ == 'xxx' assert xa.meth(x) == 4 @@ -164,9 +168,8 @@ def __call__(self): return [1,2,3] - from distributed import test_env a = A() - protocol = test_env({'a': a}) + protocol = self.test_env({'a': a}) xa = protocol.get_remote('a') xa.meth(B()) assert xa.perform() == 4 @@ -174,20 +177,17 @@ def test_frame(self): #skip("Land of infinite recursion") import sys - from distributed import test_env f = sys._getframe() - protocol = test_env({'f':f}) + protocol = self.test_env({'f':f}) xf = protocol.get_remote('f') assert f.f_globals.keys() == xf.f_globals.keys() assert f.f_locals.keys() == xf.f_locals.keys() def test_remote_exception(self): - from distributed import test_env - def raising(): 1/0 - protocol = test_env({'raising':raising}) + protocol = self.test_env({'raising':raising}) xr = protocol.get_remote('raising') try: xr() @@ -200,11 +200,9 @@ def test_instantiate_remote_type(self): skip("Land of infinite recursion") - from distributed import test_env - class C: pass - protocol = test_env({'C':C}) + protocol = self.test_env({'C':C}) xC = protocol.get_remote('C') xC() From fijal at codespeak.net Thu Mar 1 15:03:44 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 1 Mar 2007 15:03:44 +0100 (CET) Subject: [pypy-svn] r39633 - pypy/dist/pypy/lib/distributed/demo Message-ID: <20070301140344.D5CA910117@code0.codespeak.net> Author: fijal Date: Thu Mar 1 15:03:42 2007 New Revision: 39633 Added: pypy/dist/pypy/lib/distributed/demo/gsock.py Log: (fijal, guido) add a cool demo about lib/distributed Added: pypy/dist/pypy/lib/distributed/demo/gsock.py ============================================================================== --- (empty file) +++ pypy/dist/pypy/lib/distributed/demo/gsock.py Thu Mar 1 15:03:42 2007 @@ -0,0 +1,38 @@ + +from distributed import RemoteProtocol, remote_loop + +class X: + def __init__(self, z): + self.z = z + + def meth(self, x): + return self.z + x() + + def raising(self): + 1/0 + +x = X(3) + +def remote(): + from distributed.socklayer import socket_listener + send, receive = socket_listener() + remote_loop(RemoteProtocol(send, receive, globals())) + +def local(): + from distributed.socklayer import socket_connecter + send, receive = socket_connecter(('localhost', 12121)) + return RemoteProtocol(send, receive) + +import sys +if __name__ == '__main__': + if len(sys.argv) > 1 and sys.argv[1] == '-r': + remote() + else: + rp = local() + x = rp.get_remote("x") + try: + x.raising() + except: + import sys + import pdb + pdb.post_mortem(sys.exc_info()[2]) From fijal at codespeak.net Thu Mar 1 15:06:06 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 1 Mar 2007 15:06:06 +0100 (CET) Subject: [pypy-svn] r39634 - pypy/dist/pypy/lib/distributed Message-ID: <20070301140606.5AE051011E@code0.codespeak.net> Author: fijal Date: Thu Mar 1 15:06:04 2007 New Revision: 39634 Added: pypy/dist/pypy/lib/distributed/socklayer.py Log: Needed for demo Added: pypy/dist/pypy/lib/distributed/socklayer.py ============================================================================== --- (empty file) +++ pypy/dist/pypy/lib/distributed/socklayer.py Thu Mar 1 15:06:04 2007 @@ -0,0 +1,37 @@ + +from pypeers.pipe.gsocket import GreenSocket +from socket import socket, AF_INET, SOCK_STREAM +import marshal +import sys + +TRACE = False +def trace(msg): + if TRACE: + print >>sys.stderr, msg + +def receive(conn): + all = [] + data = conn.recv(10000) + trace("received %s" % data) + return marshal.loads(data) + +def send(conn, data): + trace("sending %s" % (data,)) + conn.send(marshal.dumps(data)) + trace("done") + +def socket_listener(address=('', 12121)): + s = GreenSocket(AF_INET, SOCK_STREAM) + s.bind(address) + s.listen(1) + print "Waiting for connection" + conn, addr = s.accept() + + return lambda data : send(conn, data), lambda : receive(conn) + +def socket_connecter(address): + s = GreenSocket(AF_INET, SOCK_STREAM) + print "Connecting %s" % (address,) + s.connect(address) + + return lambda data : send(s, data), lambda : receive(s) From fijal at codespeak.net Thu Mar 1 15:06:29 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 1 Mar 2007 15:06:29 +0100 (CET) Subject: [pypy-svn] r39635 - pypy/dist/pypy/lib/distributed/test Message-ID: <20070301140629.7BF1110120@code0.codespeak.net> Author: fijal Date: Thu Mar 1 15:06:27 2007 New Revision: 39635 Added: pypy/dist/pypy/lib/distributed/test/__init__.py Log: From arigo at codespeak.net Thu Mar 1 19:58:48 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 1 Mar 2007 19:58:48 +0100 (CET) Subject: [pypy-svn] r39642 - pypy/dist/pypy/doc Message-ID: <20070301185848.EBCBC100D1@code0.codespeak.net> Author: arigo Date: Thu Mar 1 19:58:39 2007 New Revision: 39642 Modified: pypy/dist/pypy/doc/objspace.txt Log: More documentation about how the Standard Object Space works, at least at the level of multiple type implementations, multimethods, and slicing. Modified: pypy/dist/pypy/doc/objspace.txt ============================================================================== --- pypy/dist/pypy/doc/objspace.txt (original) +++ pypy/dist/pypy/doc/objspace.txt Thu Mar 1 19:58:39 2007 @@ -289,7 +289,7 @@ does some internal dispatching (similar to "Object/abstract.c" in CPython) and invokes a method of the proper W_XyzObject class that can do the operation. The operation itself is done with the primitives allowed by -RestrictedPython. The result is constructed as a wrapped object again. For +RPython. The result is constructed as a wrapped object again. For example, compare the following implementation of integer addition with the function "int_add()" in "Object/intobject.c": :: @@ -313,23 +313,15 @@ CPython would be to use PyObject* pointers all around except when the object is an integer (after all, integers are directly available in C too). You could represent small integers as odd-valuated pointers. But it puts extra burden on -the whole C code, so the CPython team avoided it. - -In our case it is a later optimization that we could make. We just don't want -to make it now (and certainly not hard-coded at this level -- it could be -introduced by the code generators at translation time). So in summary: wrapping -integers as instances is the simple path, while using plain integers instead is -the complex path, not the other way around. - -Note that the Standard Object Space implementation uses MultiMethod_ dispatch -instead of the complex rules of "Object/abstract.c". This can probably be -translated to a different low-level dispatch implementation that would be -binary compatible with CPython's (basically the PyTypeObject structure and its -function pointers). If compatibility is not required it will be more -straightforwardly converted into some efficient multimethod code. +the whole C code, so the CPython team avoided it. (In our case it is an +optimization that we eventually made, but not hard-coded at this level - +see `object optimizations`_.) + +So in summary: wrapping integers as instances is the simple path, while +using plain integers instead is the complex path, not the other way +around. .. _StdObjSpace: ../objspace/std/ -.. _MultiMethod: theory.html#multimethods Object types @@ -358,26 +350,145 @@ "real" implementation of tuples: the way the data is stored in the ``W_TupleObject`` class, how the operations work, etc. -The goal of the above module layout is to cleanly separate the Python type -object, visible to the user, and the actual implementation of its instances. It -is possible to provide *several* implementations of the -instances of the same Python type. The ``__new__()`` method could decide to -create one or the other. From the user's point of view, they are still all -instances of exactly the same type; the possibly multiple internal -``W_XxxObject`` classes are not visible. PyPy knows that (e.g.) the -application-level type of its interpreter-level ``W_TupleObject`` instances is -"tuple" because there is a ``typedef`` class attribute in ``W_TupleObject`` -which points back to the tuple type specification from `tupletype.py`_. For -examples of having several implementations of the same type, see the `object -optimizations`_ page. +The goal of the above module layout is to cleanly separate the Python +type object, visible to the user, and the actual implementation of its +instances. It is possible to provide *several* implementations of the +instances of the same Python type, by writing several ``W_XxxObject`` +classes. Every place that instantiates a new object of that Python type +can decide which ``W_XxxObject`` class to instantiate. For example, the +regular string implementation is ``W_StringObject``, but we also have a +``W_StringSliceObject`` class whose instances contain a string, a start +index, and a stop index; it is used as the result of a string slicing +operation to avoid the copy of all the characters in the slice into a +new buffer. + +From the user's point of view, the multiple internal ``W_XxxObject`` +classes are not visible: they are still all instances of exactly the +same Python type. PyPy knows that (e.g.) the application-level type of +its interpreter-level ``W_StringObject`` instances is "str" because +there is a ``typedef`` class attribute in ``W_StringObject`` which +points back to the string type specification from `stringtype.py`_; all +other implementations of strings use the same ``typedef`` from +`stringtype.py`_. + +For other examples of multiple implementations of the same Python type, +see the `object optimizations`_ page. .. _`listtype.py`: ../objspace/std/listtype.py +.. _`stringtype.py`: ../objspace/std/stringtype.py .. _`tupletype.py`: ../objspace/std/tupletype.py .. _`tupleobject.py`: ../objspace/std/tupleobject.py .. _`object optimizations`: object-optimizations.html +Multimethods +------------ + +The Standard Object Space allows multiple object implementations per +Python type - this is based on multimethods_, although the more precise +picture spans several levels in order to emulate the exact Python +semantics. + +Consider the example of the ``space.getitem(w_a, w_b)`` operation, +corresponding to the application-level syntax ``a[b]``. The Standard +Object Space contains a corresponding ``getitem`` multimethod and a +family of functions that implement the multimethod for various +combination of argument classes - more precisely, for various +combinations of the *interpreter-level* classes of the arguments. Here +are some examples of functions implementing the ``getitem`` +multimethod: + +* ``getitem__Tuple_ANY``: called when the first argument is a + W_TupleObject, this function converts its second argument to an + integer and performs tuple indexing. + +* ``getitem__Tuple_Slice``: called when the first argument is a + W_TupleObject and the second argument is a W_SliceObject. This + version takes precedence over the previous one if the indexing is + done with a slice object, and performs tuple slicing instead. + +* ``getitem__String_Slice``: called when the first argument is a + W_StringObject and the second argument is a slice object. When the + special string slices optimization is enabled, this returns an + instance of W_StringSliceObject. + +* ``getitem__StringSlice_ANY``: called when the first argument is a + W_StringSliceObject. This implementation adds the provided index to + the original start of the slice stored in the W_StringSliceObject + instance. This allows constructs like ``a = s[10:100]; print a[5]`` + to return the 15th character of ``s`` without having to perform any + buffer copying. + +Note how the multimethod dispatch logic helps writing new object +implementations without having to insert hooks into existing code. Note +first how we could have defined a regular method-based API that new +object implementations must provide, and call these methods from the +space operations. The problem with this approach is that some Python +operators are naturally binary or N-ary. Consider for example the +addition operation: for the basic string implementation it is a simple +concatenation-by-copy, but it can have a rather more subtle +implementation for strings done as ropes. It is also likely that +concatenating a basic string with a rope string could have its own +dedicated implementation - and yet another implementation for a rope +string with a basic string. With multimethods, we can have an +orthogonally-defined implementation for each combination. + +The multimethods mechanism also supports delegate functions, which are +converters between two object implementations. The dispatch logic knows +how to insert calls to delegates if it encounters combinations of +interp-level classes which is not directly implemented. For example, we +have no specific implementation for the concatenation of a basic string +and a StringSlice object; when the user adds two such strings, then the +StringSlice object is converted to a basic string (that is, a +temporarily copy is built), and the concatenation is performed on the +resulting pair of basic strings. This is similar to the C++ method +overloading resolution mechanism (but occurs at runtime). + +.. _multimethods: theory.html#multimethods + + +Multimethod slicing +------------------- + +The complete picture is more complicated because the Python object model +is based on *descriptors*: the types ``int``, ``str``, etc. must have +methods ``__add__``, ``__mul__``, etc. that take two arguments including +the ``self``. These methods must perform the operation or return +``NotImplemented`` if the second argument is not of a type that it +doesn't know how to handle. + +The Standard Object Space creates these methods by *slicing* the +multimethod tables. Each method is automatically generated from a +subset of the registered implementations of the corresponding +multimethod. This slicing is performed on the first argument, in order +to keep only the implementations whose first argument's +interpreter-level class matches the declared Python-level type. + +For example, in a baseline PyPy, ``int.__add__`` is just calling the +function ``add__Int_Int``, which is the only registered implementation +for ``add`` whose first argument is an implementation of the ``int`` +Python type. On the other hand, if we enable integers implemented as +tagged pointers, then there is another matching implementation: +``add__SmallInt_SmallInt``. In this case, the Python-level method +``int.__add__`` is implemented by trying to dispatch between these two +functions based on the interp-level type of the two arguments. + +Similarly, the reverse methods (``__radd__`` and others) are obtained by +slicing the multimethod tables to keep only the functions whose *second* +argument has the correct Python-level type. + +Slicing is actually a good way to reproduce the details of the object +model as seen in CPython: slicing is attempted for every Python types +for every multimethod, but the ``__xyz__`` Python methods are only put +into the Python type when the resulting slices are not empty. This is +how our ``int`` type has no ``__getitem__`` method, for example. +Additionally, slicing ensures that ``5 .__add__(6L)`` correctly returns +``NotImplemented`` (because this particular slice does not include +``add__Long_Long`` and there is no ``add__Int_Long``), which leads to +``6L.__radd__(5)`` being called, as in CPython. + + The Trace Object Space ====================== From fijal at codespeak.net Thu Mar 1 20:23:21 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 1 Mar 2007 20:23:21 +0100 (CET) Subject: [pypy-svn] r39643 - pypy/dist/pypy/lib/distributed/demo Message-ID: <20070301192321.6AEAD1006F@code0.codespeak.net> Author: fijal Date: Thu Mar 1 20:23:19 2007 New Revision: 39643 Modified: pypy/dist/pypy/lib/distributed/demo/gsock.py Log: (fijal, arigo, pedronis, arre) Minor improvements Modified: pypy/dist/pypy/lib/distributed/demo/gsock.py ============================================================================== --- pypy/dist/pypy/lib/distributed/demo/gsock.py (original) +++ pypy/dist/pypy/lib/distributed/demo/gsock.py Thu Mar 1 20:23:19 2007 @@ -20,7 +20,7 @@ def local(): from distributed.socklayer import socket_connecter - send, receive = socket_connecter(('localhost', 12121)) + send, receive = socket_connecter(('localhost', 12122)) return RemoteProtocol(send, receive) import sys From rxe at codespeak.net Thu Mar 1 20:31:36 2007 From: rxe at codespeak.net (rxe at codespeak.net) Date: Thu, 1 Mar 2007 20:31:36 +0100 (CET) Subject: [pypy-svn] r39644 - pypy/dist/pypy/translator/c/test Message-ID: <20070301193136.2C92A10125@code0.codespeak.net> Author: rxe Date: Thu Mar 1 20:31:33 2007 New Revision: 39644 Modified: pypy/dist/pypy/translator/c/test/test_newgc.py Log: (mwh, rxe) add a failing skipped test with collecting in dictionary resizing Modified: pypy/dist/pypy/translator/c/test/test_newgc.py ============================================================================== --- pypy/dist/pypy/translator/c/test/test_newgc.py (original) +++ pypy/dist/pypy/translator/c/test/test_newgc.py Thu Mar 1 20:31:33 2007 @@ -859,6 +859,35 @@ # the point is just not to segfault res = fn() + def test_dict_segfault(self): + py.test.skip("some gc collect failing - somehow") + class Element: + pass + + elements = [Element() for ii in range(10000)] + + def dostuff(): + reverse = {} + l = elements[:] + + for ii in elements: + reverse[ii] = ii + # print reverse.get(ii, None) + + for jj in range(100): + e = l[-1] + del reverse[e] + l.remove(e) + + def f(): + for ii in range(100): + print ii + dostuff() + + fn = self.getcompiled(f) + # the point is just not to segfault + res = fn() + class TestUsingStacklessFramework(TestUsingFramework): gcpolicy = "stacklessgc" From santagada at codespeak.net Fri Mar 2 03:23:59 2007 From: santagada at codespeak.net (santagada at codespeak.net) Date: Fri, 2 Mar 2007 03:23:59 +0100 (CET) Subject: [pypy-svn] r39647 - in pypy/dist/pypy/lang/js: . test Message-ID: <20070302022359.6B9EE1012D@code0.codespeak.net> Author: santagada Date: Fri Mar 2 03:23:54 2007 New Revision: 39647 Modified: pypy/dist/pypy/lang/js/interpreter.py pypy/dist/pypy/lang/js/jsobj.py pypy/dist/pypy/lang/js/test/test_interp.py Log: with operator with test Modified: pypy/dist/pypy/lang/js/interpreter.py ============================================================================== --- pypy/dist/pypy/lang/js/interpreter.py (original) +++ pypy/dist/pypy/lang/js/interpreter.py Fri Mar 2 03:23:54 2007 @@ -969,6 +969,24 @@ self.expr.eval(ctx) return w_Undefined +class With(Statement): + opcode = "WITH" + + def from_tree(self, t): + self.object = get_obj(t, 'object') + self.body = get_obj(t, 'body') + + def execute(self, ctx): + obj = self.object.eval(ctx).GetValue().ToObject() + ctx.push_object(obj) + + try: + retval = self.body.execute(ctx) + finally: + ctx.pop_object() + return retval + + class WhileBase(Statement): def from_tree(self, t): self.condition = get_obj(t, 'condition') Modified: pypy/dist/pypy/lang/js/jsobj.py ============================================================================== --- pypy/dist/pypy/lang/js/jsobj.py (original) +++ pypy/dist/pypy/lang/js/jsobj.py Fri Mar 2 03:23:54 2007 @@ -437,7 +437,7 @@ self.variable = obj def pop_object(self): - """docstring for pop_object""" + """remove the last pushed object""" return self.scope.pop(0) def resolve_identifier(self, identifier): Modified: pypy/dist/pypy/lang/js/test/test_interp.py ============================================================================== --- pypy/dist/pypy/lang/js/test/test_interp.py (original) +++ pypy/dist/pypy/lang/js/test/test_interp.py Fri Mar 2 03:23:54 2007 @@ -478,3 +478,21 @@ print(2 !== 3) print(2 !== 2) """, ['true', 'false', 'true', 'false']) + + def test_with(self): + self.assert_prints(""" + var mock = {x:2} + var x=4 + print(x) + try { + with(mock) { + print(x) + throw 3 + print("not reacheable") + } + } + catch(y){ + print(y) + } + print(x) + """, ['4', '2', '3', '4']) From cfbolz at codespeak.net Fri Mar 2 10:49:05 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Fri, 2 Mar 2007 10:49:05 +0100 (CET) Subject: [pypy-svn] r39652 - pypy/extradoc/sprintinfo/trillke-2007 Message-ID: <20070302094905.4EA2D10121@code0.codespeak.net> Author: cfbolz Date: Fri Mar 2 10:49:02 2007 New Revision: 39652 Added: pypy/extradoc/sprintinfo/trillke-2007/planning.txt Log: (all): invent lots of tasks Added: pypy/extradoc/sprintinfo/trillke-2007/planning.txt ============================================================================== --- (empty file) +++ pypy/extradoc/sprintinfo/trillke-2007/planning.txt Fri Mar 2 10:49:02 2007 @@ -0,0 +1,50 @@ +============================ +Trillke Sprint 2007 Planning +============================ + +People present: Michael, Arre, Stephan, Anto, Guido, Armin, Maciek, Bea, + Samuele, Georg, Alexander, Holger, Carl Friedrich, Anders + +Tutorial: Georg, Anders + + * think a bit about what needs to be done for 1.0 + + * move some of the external functions to the new interface (kill + suggested_primitive!!!) + + * Fix the rdict bug (Michael, Richard) + + * run application on top of PyPy and turn them into benchmarks: Guido, + Christian + + * object optimizations: ropes, list optimizations, cuckoo hashing, + tree-based dicts: after the tutorial, Holger, Armin, Carl Friedrich, Georg + + * improve the error messages of the rtyper + + * improve setups of temporary test directories + + * benchmarking: make nice graphs out of benchmark results + + * hunt the strange speed bottleneck of gencli/genjava: Anto, Samuele + + * fix application-level stackless code: Arre, Stephan + + * improve greensocks + + * have a minimal readline support for history and line editing: Armin, Holger + + * fix the javascript backend work in internet explorer: Guido, Maciek + + * make the usage of the js backend nicer + + * discuss code sharing between the js backend and gencli: Anto, Maciek + + * make genllvm less of a FrankenBackend + + * have a pypy with a gil and threading that works + + * object-level locking for a gil-less pypy + + * use no locking, multiple interpreters and shared memory instead of + object-level locks From fijal at codespeak.net Fri Mar 2 10:57:47 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 2 Mar 2007 10:57:47 +0100 (CET) Subject: [pypy-svn] r39653 - pypy/dist/pypy/module/_ssl/test Message-ID: <20070302095747.589B610131@code0.codespeak.net> Author: fijal Date: Fri Mar 2 10:57:44 2007 New Revision: 39653 Modified: pypy/dist/pypy/module/_ssl/test/test_ssl.py Log: Skip ssl tests Modified: pypy/dist/pypy/module/_ssl/test/test_ssl.py ============================================================================== --- pypy/dist/pypy/module/_ssl/test/test_ssl.py (original) +++ pypy/dist/pypy/module/_ssl/test/test_ssl.py Fri Mar 2 10:57:44 2007 @@ -1,5 +1,8 @@ from pypy.conftest import gettestobjspace import os +import py + +py.test.skip("Module not working yet") if os.name == "nt": from py.test import skip From arigo at codespeak.net Fri Mar 2 11:35:29 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 2 Mar 2007 11:35:29 +0100 (CET) Subject: [pypy-svn] r39654 - pypy/dist/pypy/translator/cli Message-ID: <20070302103529.20E2710126@code0.codespeak.net> Author: arigo Date: Fri Mar 2 11:35:26 2007 New Revision: 39654 Modified: pypy/dist/pypy/translator/cli/gencli.py Log: Mono's ilasm occasionally deadlocks. We set a timer to avoid blocking automated test runs forever. Modified: pypy/dist/pypy/translator/cli/gencli.py ============================================================================== --- pypy/dist/pypy/translator/cli/gencli.py (original) +++ pypy/dist/pypy/translator/cli/gencli.py Fri Mar 2 11:35:26 2007 @@ -80,7 +80,11 @@ ilasm = SDK.ilasm() tmpfile = self.tmpfile.strpath - self._exec_helper(ilasm, tmpfile, 'ilasm failed to assemble (%s):\n%s\n%s') + self._exec_helper(ilasm, tmpfile, + 'ilasm failed to assemble (%s):\n%s\n%s', + timeout = 900) + # Mono's ilasm occasionally deadlocks. We set a timer to avoid + # blocking automated test runs forever. exefile = tmpfile.replace('.il', '.exe') if getoption('verify'): @@ -88,8 +92,14 @@ self._exec_helper(peverify, exefile, 'peverify failed to verify (%s):\n%s\n%s') return exefile - def _exec_helper(self, helper, filename, msg): - proc = subprocess.Popen([helper, filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + def _exec_helper(self, helper, filename, msg, timeout=None): + args = [helper, filename] + if timeout and not sys.platform.startswith('win'): + import os + from pypy.tool import autopath + watchdog = os.path.join(autopath.pypydir, 'tool', 'watchdog.py') + args[:0] = [sys.executable, watchdog, str(float(timeout))] + proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = proc.communicate() retval = proc.wait() assert retval == 0, msg % (filename, stdout, stderr) From mwh at codespeak.net Fri Mar 2 12:01:24 2007 From: mwh at codespeak.net (mwh at codespeak.net) Date: Fri, 2 Mar 2007 12:01:24 +0100 (CET) Subject: [pypy-svn] r39656 - pypy/dist/pypy/translator/c/test Message-ID: <20070302110124.362561006E@code0.codespeak.net> Author: mwh Date: Fri Mar 2 12:01:13 2007 New Revision: 39656 Modified: pypy/dist/pypy/translator/c/test/test_standalone.py Log: a standalone version of the horrible dictionary bug Modified: pypy/dist/pypy/translator/c/test/test_standalone.py ============================================================================== --- pypy/dist/pypy/translator/c/test/test_standalone.py (original) +++ pypy/dist/pypy/translator/c/test/test_standalone.py Fri Mar 2 12:01:13 2007 @@ -118,3 +118,37 @@ out = py.process.cmdexec("%s 500" % exe) assert int(out) == 500*501/2 + +def test_dict_segfault(): + py.test.skip('segfaults :(') + class Element: + pass + + elements = [Element() for ii in range(10000)] + + def dostuff(): + reverse = {} + l = elements[:] + + for ii in elements: + reverse[ii] = ii#Element() + + for jj in range(100): + e = l[-1] + del reverse[e] + l.remove(e) + + def f(args): + for ii in range(100): + dostuff() + return 0 + + t = TranslationContext() + t.config.translation.gc = 'framework' + t.buildannotator().build_types(f, [s_list_of_strings]) + t.buildrtyper().specialize() + + cbuilder = CStandaloneBuilder(t, f, t.config) + cbuilder.generate_source() + cbuilder.compile() + data = cbuilder.cmdexec('') From hpk at codespeak.net Fri Mar 2 12:19:29 2007 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 2 Mar 2007 12:19:29 +0100 (CET) Subject: [pypy-svn] r39657 - pypy/dist/pypy/interpreter Message-ID: <20070302111929.08B2F10071@code0.codespeak.net> Author: hpk Date: Fri Mar 2 12:19:26 2007 New Revision: 39657 Removed: pypy/dist/pypy/interpreter/autopath.py Modified: pypy/dist/pypy/interpreter/interactive.py pypy/dist/pypy/interpreter/main.py Log: these scripts are not run anymore directly (rather the pypy/bin/* ones) and so i don't see a use in using autopath here. Modified: pypy/dist/pypy/interpreter/interactive.py ============================================================================== --- pypy/dist/pypy/interpreter/interactive.py (original) +++ pypy/dist/pypy/interpreter/interactive.py Fri Mar 2 12:19:26 2007 @@ -1,5 +1,3 @@ -import autopath - from pypy.interpreter import error from pypy.interpreter import baseobjspace, module, main import sys Modified: pypy/dist/pypy/interpreter/main.py ============================================================================== --- pypy/dist/pypy/interpreter/main.py (original) +++ pypy/dist/pypy/interpreter/main.py Fri Mar 2 12:19:26 2007 @@ -1,4 +1,3 @@ -import autopath from pypy.interpreter import module, eval from pypy.interpreter.error import OperationError from pypy.interpreter.pycode import PyCode From guido at codespeak.net Fri Mar 2 12:45:24 2007 From: guido at codespeak.net (guido at codespeak.net) Date: Fri, 2 Mar 2007 12:45:24 +0100 (CET) Subject: [pypy-svn] r39658 - pypy/dist/pypy/translator/js/modules Message-ID: <20070302114524.0FB4B10070@code0.codespeak.net> Author: guido Date: Fri Mar 2 12:45:22 2007 New Revision: 39658 Modified: pypy/dist/pypy/translator/js/modules/mochikit.py Log: Trying to add some MochiKit.Signal stuff, not working yet. Modified: pypy/dist/pypy/translator/js/modules/mochikit.py ============================================================================== --- pypy/dist/pypy/translator/js/modules/mochikit.py (original) +++ pypy/dist/pypy/translator/js/modules/mochikit.py Fri Mar 2 12:45:22 2007 @@ -2,12 +2,17 @@ """ mochikit wrappers """ -from pypy.rpython.extfunc import register_external +from pypy.rpython.extfunc import _callable, register_external +from pypy.translator.js.modules import dom + +# MochiKit.LoggingPane def createLoggingPane(var): pass register_external(createLoggingPane, args=[bool]) +# MochiKit.Logging + def log(data): print data register_external(log, args=None) @@ -28,10 +33,26 @@ print "FATAL:", data register_external(logFatal, args=None) +# MochiKit.DOM + def escapeHTML(data): return data register_external(escapeHTML, args=[str], result=str) +# MochiKit.Base + def serializeJSON(data): pass register_external(serializeJSON, args=None, result=str) + +# MochiKit.Signal + +def connect(src, signal, dest): + print 'connecting event %s' % (event,) +register_external(connect, args=[dom.EventTarget, str, _callable([dom.Event])], + result=int) + +def disconnect(id): + pass +register_external(disconnect, args=[int]) + From hpk at codespeak.net Fri Mar 2 12:48:05 2007 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 2 Mar 2007 12:48:05 +0100 (CET) Subject: [pypy-svn] r39659 - pypy/dist/pypy/interpreter/test Message-ID: <20070302114805.7AE6310063@code0.codespeak.net> Author: hpk Date: Fri Mar 2 12:48:03 2007 New Revision: 39659 Removed: pypy/dist/pypy/interpreter/test/autopath.py Modified: pypy/dist/pypy/interpreter/test/test_compiler.py pypy/dist/pypy/interpreter/test/test_eval.py pypy/dist/pypy/interpreter/test/test_exceptcomp.py pypy/dist/pypy/interpreter/test/test_exec.py pypy/dist/pypy/interpreter/test/test_function.py pypy/dist/pypy/interpreter/test/test_gateway.py pypy/dist/pypy/interpreter/test/test_generator.py pypy/dist/pypy/interpreter/test/test_main.py pypy/dist/pypy/interpreter/test/test_module.py pypy/dist/pypy/interpreter/test/test_nestedscope.py pypy/dist/pypy/interpreter/test/test_objspace.py pypy/dist/pypy/interpreter/test/test_py.py pypy/dist/pypy/interpreter/test/test_pyframe.py pypy/dist/pypy/interpreter/test/test_raise.py pypy/dist/pypy/interpreter/test/test_special.py pypy/dist/pypy/interpreter/test/test_typedef.py Log: removing some more obsolete autopath usages on a sidenote Modified: pypy/dist/pypy/interpreter/test/test_compiler.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_compiler.py (original) +++ pypy/dist/pypy/interpreter/test/test_compiler.py Fri Mar 2 12:48:03 2007 @@ -1,5 +1,4 @@ import __future__ -import autopath import py, sys from pypy.interpreter.pycompiler import CPythonCompiler, PythonAstCompiler from pypy.interpreter.pycode import PyCode Modified: pypy/dist/pypy/interpreter/test/test_eval.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_eval.py (original) +++ pypy/dist/pypy/interpreter/test/test_eval.py Fri Mar 2 12:48:03 2007 @@ -1,5 +1,4 @@ -import autopath from pypy.interpreter.eval import Frame from pypy.interpreter.pycode import PyCode Modified: pypy/dist/pypy/interpreter/test/test_exceptcomp.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_exceptcomp.py (original) +++ pypy/dist/pypy/interpreter/test/test_exceptcomp.py Fri Mar 2 12:48:03 2007 @@ -2,7 +2,6 @@ New for PyPy - Could be incorporated into CPython regression tests. """ -import autopath class AppTestExceptionComp: Modified: pypy/dist/pypy/interpreter/test/test_exec.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_exec.py (original) +++ pypy/dist/pypy/interpreter/test/test_exec.py Fri Mar 2 12:48:03 2007 @@ -2,7 +2,6 @@ New for PyPy - Could be incorporated into CPython regression tests. """ -import autopath from pypy.tool.udir import udir Modified: pypy/dist/pypy/interpreter/test/test_function.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_function.py (original) +++ pypy/dist/pypy/interpreter/test/test_function.py Fri Mar 2 12:48:03 2007 @@ -1,5 +1,4 @@ -import autopath import unittest from pypy.interpreter.function import Function, Method, descr_function_get from pypy.interpreter.pycode import PyCode Modified: pypy/dist/pypy/interpreter/test/test_gateway.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_gateway.py (original) +++ pypy/dist/pypy/interpreter/test/test_gateway.py Fri Mar 2 12:48:03 2007 @@ -1,5 +1,4 @@ -import autopath from pypy.interpreter import gateway from pypy.interpreter import argument import py Modified: pypy/dist/pypy/interpreter/test/test_generator.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_generator.py (original) +++ pypy/dist/pypy/interpreter/test/test_generator.py Fri Mar 2 12:48:03 2007 @@ -1,5 +1,4 @@ from __future__ import generators -import autopath class AppTestGenerator: Modified: pypy/dist/pypy/interpreter/test/test_main.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_main.py (original) +++ pypy/dist/pypy/interpreter/test/test_main.py Fri Mar 2 12:48:03 2007 @@ -1,4 +1,3 @@ -import autopath from cStringIO import StringIO import py Modified: pypy/dist/pypy/interpreter/test/test_module.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_module.py (original) +++ pypy/dist/pypy/interpreter/test/test_module.py Fri Mar 2 12:48:03 2007 @@ -1,5 +1,4 @@ -import autopath from pypy.interpreter.module import Module class TestModule: Modified: pypy/dist/pypy/interpreter/test/test_nestedscope.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_nestedscope.py (original) +++ pypy/dist/pypy/interpreter/test/test_nestedscope.py Fri Mar 2 12:48:03 2007 @@ -1,4 +1,3 @@ -import autopath class AppTestNestedScope: Modified: pypy/dist/pypy/interpreter/test/test_objspace.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_objspace.py (original) +++ pypy/dist/pypy/interpreter/test/test_objspace.py Fri Mar 2 12:48:03 2007 @@ -1,4 +1,3 @@ -import autopath from py.test import raises from pypy.interpreter.function import Function from pypy.interpreter.pycode import PyCode Modified: pypy/dist/pypy/interpreter/test/test_py.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_py.py (original) +++ pypy/dist/pypy/interpreter/test/test_py.py Fri Mar 2 12:48:03 2007 @@ -1,10 +1,10 @@ -import autopath from pypy.tool.udir import udir import py import sys +import pypy -pypypath = str(py.path.local(autopath.pypydir).join('bin', 'py.py')) +pypypath = py.path.local(pypy.__file__).dirpath("bin", "py.py") def test_executable(): """Ensures sys.executable points to the py.py script""" Modified: pypy/dist/pypy/interpreter/test/test_pyframe.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_pyframe.py (original) +++ pypy/dist/pypy/interpreter/test/test_pyframe.py Fri Mar 2 12:48:03 2007 @@ -1,4 +1,3 @@ -import autopath class AppTestPyFrame: Modified: pypy/dist/pypy/interpreter/test/test_raise.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_raise.py (original) +++ pypy/dist/pypy/interpreter/test/test_raise.py Fri Mar 2 12:48:03 2007 @@ -1,4 +1,3 @@ -import autopath class AppTestRaise: Modified: pypy/dist/pypy/interpreter/test/test_special.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_special.py (original) +++ pypy/dist/pypy/interpreter/test/test_special.py Fri Mar 2 12:48:03 2007 @@ -1,5 +1,4 @@ -import autopath class AppTestSpecialTestCase: def test_Ellipsis(self): Modified: pypy/dist/pypy/interpreter/test/test_typedef.py ============================================================================== --- pypy/dist/pypy/interpreter/test/test_typedef.py (original) +++ pypy/dist/pypy/interpreter/test/test_typedef.py Fri Mar 2 12:48:03 2007 @@ -1,4 +1,3 @@ -import autopath # this test isn't so much to test that the objspace interface *works* # -- it's more to test that it's *there* From fijal at codespeak.net Fri Mar 2 12:49:58 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 2 Mar 2007 12:49:58 +0100 (CET) Subject: [pypy-svn] r39660 - pypy/dist/pypy/rpython Message-ID: <20070302114958.E312510063@code0.codespeak.net> Author: fijal Date: Fri Mar 2 12:49:56 2007 New Revision: 39660 Modified: pypy/dist/pypy/rpython/extfunc.py Log: Postpone annotation() a bit Modified: pypy/dist/pypy/rpython/extfunc.py ============================================================================== --- pypy/dist/pypy/rpython/extfunc.py (original) +++ pypy/dist/pypy/rpython/extfunc.py Fri Mar 2 12:49:56 2007 @@ -27,12 +27,15 @@ class ExtFuncEntry(ExtRegistryEntry): def compute_result_annotation(self, *args_s): if self.signature_args is not None: - assert len(args_s) == len(self.signature_args),\ + signature_args = [annotation(arg, self.bookkeeper) + for arg in self.signature_args] + assert len(args_s) == len(signature_args),\ "Argument number mismatch" - for arg, expected in zip(args_s, self.signature_args): + for arg, expected in zip(args_s, signature_args): arg = unionof(arg, expected) assert expected.contains(arg) - return self.signature_result + signature_result = annotation(self.signature_result, self.bookkeeper) + return signature_result def specialize_call(self, hop): rtyper = hop.rtyper @@ -65,8 +68,8 @@ if args is None: signature_args = None else: - signature_args = [annotation(arg) for arg in args] - signature_result = annotation(result) + signature_args = args + signature_result = result name=export_name if llimpl: lltypeimpl = llimpl From arigo at codespeak.net Fri Mar 2 12:50:56 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 2 Mar 2007 12:50:56 +0100 (CET) Subject: [pypy-svn] r39661 - in pypy/dist/pypy/module: __builtin__ readline Message-ID: <20070302115056.18CC610068@code0.codespeak.net> Author: arigo Date: Fri Mar 2 12:50:52 2007 New Revision: 39661 Modified: pypy/dist/pypy/module/__builtin__/app_io.py pypy/dist/pypy/module/readline/__init__.py pypy/dist/pypy/module/readline/c_readline.py Log: (hpk, arigo) Link the readline module's readline() function with raw_input(). Should give basic (no-completion) readline support in a translated pypy-c. Modified: pypy/dist/pypy/module/__builtin__/app_io.py ============================================================================== --- pypy/dist/pypy/module/__builtin__/app_io.py (original) +++ pypy/dist/pypy/module/__builtin__/app_io.py Fri Mar 2 12:50:52 2007 @@ -35,22 +35,31 @@ On Unix, GNU readline is used if enabled. The prompt string, if given, is printed without a trailing newline before reading.""" try: - sys.stdin + stdin = sys.stdin except AttributeError: - raise RuntimeError("[raw_]input: lost sys.stdin"); + raise RuntimeError("[raw_]input: lost sys.stdin") try: - sys.stdout + stdout = sys.stdout except AttributeError: - raise RuntimeError("[raw_]input: lost sys.stdout"); + raise RuntimeError("[raw_]input: lost sys.stdout") + + # hook for the readline module + if (hasattr(sys, '__raw_input__') and + isinstance(stdin, file) and stdin.fileno() == 0 and stdin.isatty() and + isinstance(stdout, file) and stdout.fileno() == 1): + if prompt is None: + prompt = '' + return sys.__raw_input__(prompt) + if prompt is not None: - sys.stdout.write(prompt) + stdout.write(prompt) try: - flush = sys.stdout.flush + flush = stdout.flush except AttributeError: pass else: flush() - line = sys.stdin.readline() + line = stdin.readline() if not line: # inputting an empty line gives line == '\n' raise EOFError if line[-1] == '\n': Modified: pypy/dist/pypy/module/readline/__init__.py ============================================================================== --- pypy/dist/pypy/module/readline/__init__.py (original) +++ pypy/dist/pypy/module/readline/__init__.py Fri Mar 2 12:50:52 2007 @@ -10,9 +10,9 @@ """Importing this module enables command line editing using GNU readline.""" # the above line is the doc string of the translated module - def init(self, space): + def setup_after_space_initialization(self): from pypy.module.readline import c_readline - c_readline.setup_readline(space, self) + c_readline.setup_readline(self.space, self) interpleveldefs = { 'readline' : 'interp_readline.readline', Modified: pypy/dist/pypy/module/readline/c_readline.py ============================================================================== --- pypy/dist/pypy/module/readline/c_readline.py (original) +++ pypy/dist/pypy/module/readline/c_readline.py Fri Mar 2 12:50:52 2007 @@ -1,5 +1,7 @@ from ctypes import * from pypy.rpython.rctypes.tool.ctypes_platform import configure, Library +from pypy.interpreter.error import OperationError +from pypy.interpreter.gateway import ObjSpace, interp2app #------------------------------------------------------------ # configuration for binding to external readline library @@ -30,9 +32,15 @@ # special initialization of readline def setup_readline(space, w_module): - # XXX ... c_rl_initialize() - space.readline_func = readline_func - -def readline_func(s): - return c_readline(s) + # install sys.__raw_input__, a hook that will be used by raw_input() + space.setitem(space.sys.w_dict, space.wrap('__raw_input__'), + space.wrap(app_readline_func)) + +def readline_func(space, prompt): + res = c_readline(prompt) + if res is None: + raise OperationError(space.w_EOFError, space.w_None) + return space.wrap(res) +readline_func.unwrap_spec = [ObjSpace, str] +app_readline_func = interp2app(readline_func) From fijal at codespeak.net Fri Mar 2 12:51:38 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 2 Mar 2007 12:51:38 +0100 (CET) Subject: [pypy-svn] r39662 - pypy/dist/pypy/rpython Message-ID: <20070302115138.1B0881006E@code0.codespeak.net> Author: fijal Date: Fri Mar 2 12:51:36 2007 New Revision: 39662 Modified: pypy/dist/pypy/rpython/extfunc.py Log: Store the result Modified: pypy/dist/pypy/rpython/extfunc.py ============================================================================== --- pypy/dist/pypy/rpython/extfunc.py (original) +++ pypy/dist/pypy/rpython/extfunc.py Fri Mar 2 12:51:36 2007 @@ -27,15 +27,16 @@ class ExtFuncEntry(ExtRegistryEntry): def compute_result_annotation(self, *args_s): if self.signature_args is not None: - signature_args = [annotation(arg, self.bookkeeper) - for arg in self.signature_args] + self.signature_args = [annotation(arg, self.bookkeeper) + for arg in self.signature_args] assert len(args_s) == len(signature_args),\ "Argument number mismatch" for arg, expected in zip(args_s, signature_args): arg = unionof(arg, expected) assert expected.contains(arg) - signature_result = annotation(self.signature_result, self.bookkeeper) - return signature_result + self.signature_result = \ + annotation(self.signature_result, self.bookkeeper) + return self.signature_result def specialize_call(self, hop): rtyper = hop.rtyper From fijal at codespeak.net Fri Mar 2 12:53:06 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 2 Mar 2007 12:53:06 +0100 (CET) Subject: [pypy-svn] r39663 - pypy/dist/pypy/rpython Message-ID: <20070302115306.2C2B010070@code0.codespeak.net> Author: fijal Date: Fri Mar 2 12:53:02 2007 New Revision: 39663 Modified: pypy/dist/pypy/rpython/extfunc.py Log: Typo Modified: pypy/dist/pypy/rpython/extfunc.py ============================================================================== --- pypy/dist/pypy/rpython/extfunc.py (original) +++ pypy/dist/pypy/rpython/extfunc.py Fri Mar 2 12:53:02 2007 @@ -29,9 +29,9 @@ if self.signature_args is not None: self.signature_args = [annotation(arg, self.bookkeeper) for arg in self.signature_args] - assert len(args_s) == len(signature_args),\ + assert len(args_s) == len(self.signature_args),\ "Argument number mismatch" - for arg, expected in zip(args_s, signature_args): + for arg, expected in zip(args_s, self.signature_args): arg = unionof(arg, expected) assert expected.contains(arg) self.signature_result = \ From fijal at codespeak.net Fri Mar 2 13:09:00 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 2 Mar 2007 13:09:00 +0100 (CET) Subject: [pypy-svn] r39664 - in pypy/dist/pypy/annotation: . test Message-ID: <20070302120900.C0E871007C@code0.codespeak.net> Author: fijal Date: Fri Mar 2 13:08:58 2007 New Revision: 39664 Modified: pypy/dist/pypy/annotation/binaryop.py pypy/dist/pypy/annotation/test/test_annrpython.py Log: (fijal, guido) - unionof for two BasicExternals Modified: pypy/dist/pypy/annotation/binaryop.py ============================================================================== --- pypy/dist/pypy/annotation/binaryop.py (original) +++ pypy/dist/pypy/annotation/binaryop.py Fri Mar 2 13:08:58 2007 @@ -20,6 +20,7 @@ from pypy.annotation.model import add_knowntypedata, merge_knowntypedata from pypy.annotation.model import lltype_to_annotation from pypy.annotation.model import SomeGenericCallable +from pypy.annotation.model import SomeExternalBuiltin from pypy.annotation.bookkeeper import getbookkeeper from pypy.objspace.flow.model import Variable from pypy.annotation.listdef import ListDef @@ -747,6 +748,20 @@ return SomeExternalObject(ext1.knowntype) return SomeObject() +class __extend__(pairtype(SomeExternalBuiltin, SomeExternalBuiltin)): + def union((ext1, ext2)): + def commonsuperclass(cls1, cls2): + cls = cls2 + while not issubclass(cls1, cls): + cls = cls.__bases__[0] + return cls + + from pypy.rpython.ootypesystem.bltregistry import BasicExternal, ExternalType + cls = commonsuperclass(ext1.knowntype._class_, ext2.knowntype._class_) + if cls is BasicExternal: + return SomeObject() + return SomeExternalBuiltin(ExternalType(cls)) + # ____________________________________________________________ # annotation of low-level types from pypy.annotation.model import SomePtr, SomeOOInstance, SomeOOClass Modified: pypy/dist/pypy/annotation/test/test_annrpython.py ============================================================================== --- pypy/dist/pypy/annotation/test/test_annrpython.py (original) +++ pypy/dist/pypy/annotation/test/test_annrpython.py Fri Mar 2 13:08:58 2007 @@ -2634,6 +2634,30 @@ s = a.build_types(fun, [bool]) assert isinstance(s, annmodel.SomeInteger) + def test_unionof_some_external_builtin(self): + from pypy.rpython.ootypesystem.bltregistry import BasicExternal + + class A(BasicExternal): + pass + + class B(A): + pass + + class C(A): + pass + + def f(x): + if x: + return B() + else: + return C() + + P = policy.AnnotatorPolicy() + P.allow_someobjects = False + a = self.RPythonAnnotator(policy=P) + s = a.build_types(f, [bool]) + assert isinstance(s, annmodel.SomeExternalBuiltin) + def g(n): return [0,1,2,n] @@ -2651,3 +2675,4 @@ class Freezing: def _freeze_(self): return True + From mwh at codespeak.net Fri Mar 2 13:21:33 2007 From: mwh at codespeak.net (mwh at codespeak.net) Date: Fri, 2 Mar 2007 13:21:33 +0100 (CET) Subject: [pypy-svn] r39665 - in pypy/dist/pypy/rpython/memory/gctransform: . test Message-ID: <20070302122133.36B2B10069@code0.codespeak.net> Author: mwh Date: Fri Mar 2 13:21:29 2007 New Revision: 39665 Modified: pypy/dist/pypy/rpython/memory/gctransform/framework.py pypy/dist/pypy/rpython/memory/gctransform/test/test_framework.py Log: (mwh, rxe) fix the "rdict bug": it turned out that the framework gc didn't recognize zero_malloc and zero_malloc_varsize as being operations that could collect, and dictionary resizing was a function that only allocated via these operations. what was special about the test cases was that they did most of their allocations during resizing when there were no other references to the dict, most programs never see a collect there. this may just be a bug that could crash pypy-c, but it seems unlikely. Modified: pypy/dist/pypy/rpython/memory/gctransform/framework.py ============================================================================== --- pypy/dist/pypy/rpython/memory/gctransform/framework.py (original) +++ pypy/dist/pypy/rpython/memory/gctransform/framework.py Fri Mar 2 13:21:29 2007 @@ -16,7 +16,7 @@ class CollectAnalyzer(graphanalyze.GraphAnalyzer): def operation_is_true(self, op): return op.opname in ("malloc", "malloc_varsize", "gc__collect", - "gc_x_become") + "gc_x_become", "zero_malloc_varsize", "zero_malloc") ADDRESS_VOID_FUNC = lltype.FuncType([llmemory.Address], lltype.Void) Modified: pypy/dist/pypy/rpython/memory/gctransform/test/test_framework.py ============================================================================== --- pypy/dist/pypy/rpython/memory/gctransform/test/test_framework.py (original) +++ pypy/dist/pypy/rpython/memory/gctransform/test/test_framework.py Fri Mar 2 13:21:29 2007 @@ -1,5 +1,5 @@ from pypy.rpython.memory.gctransform.test.test_transform import rtype -from pypy.rpython.memory.gctransform.framework import FrameworkGCTransformer +from pypy.rpython.memory.gctransform.framework import FrameworkGCTransformer, CollectAnalyzer from pypy.rpython.lltypesystem import lltype from pypy.translator.c.gc import FrameworkGcPolicy from pypy.translator.translator import TranslationContext, graphof @@ -45,3 +45,11 @@ res = llinterp.eval_graph(entrygraph, [ll_argv]) assert ''.join(res.chars) == "2" + +def test_cancollect(): + S = lltype.GcStruct('S', ('x', lltype.Signed)) + def g(): + lltype.malloc(S, zero=True) + t = rtype(g, []) + gg = graphof(t, g) + assert CollectAnalyzer(t).analyze_direct_call(gg) From guido at codespeak.net Fri Mar 2 13:48:40 2007 From: guido at codespeak.net (guido at codespeak.net) Date: Fri, 2 Mar 2007 13:48:40 +0100 (CET) Subject: [pypy-svn] r39666 - pypy/dist/pypy/rpython Message-ID: <20070302124840.301E510126@code0.codespeak.net> Author: guido Date: Fri Mar 2 13:48:38 2007 New Revision: 39666 Modified: pypy/dist/pypy/rpython/extfunc.py Log: Revert changes Modified: pypy/dist/pypy/rpython/extfunc.py ============================================================================== --- pypy/dist/pypy/rpython/extfunc.py (original) +++ pypy/dist/pypy/rpython/extfunc.py Fri Mar 2 13:48:38 2007 @@ -27,15 +27,11 @@ class ExtFuncEntry(ExtRegistryEntry): def compute_result_annotation(self, *args_s): if self.signature_args is not None: - self.signature_args = [annotation(arg, self.bookkeeper) - for arg in self.signature_args] assert len(args_s) == len(self.signature_args),\ "Argument number mismatch" for arg, expected in zip(args_s, self.signature_args): arg = unionof(arg, expected) assert expected.contains(arg) - self.signature_result = \ - annotation(self.signature_result, self.bookkeeper) return self.signature_result def specialize_call(self, hop): @@ -69,8 +65,8 @@ if args is None: signature_args = None else: - signature_args = args - signature_result = result + signature_args = [annotation(arg, None) for arg in args] + signature_result = annotation(result, None) name=export_name if llimpl: lltypeimpl = llimpl From hpk at codespeak.net Fri Mar 2 13:51:43 2007 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 2 Mar 2007 13:51:43 +0100 (CET) Subject: [pypy-svn] r39667 - pypy/dist/pypy/objspace/test Message-ID: <20070302125143.A778B10126@code0.codespeak.net> Author: hpk Date: Fri Mar 2 13:51:40 2007 New Revision: 39667 Removed: pypy/dist/pypy/objspace/test/autopath.py Modified: pypy/dist/pypy/objspace/test/test_descriptor.py pypy/dist/pypy/objspace/test/test_traceobjspace.py Log: remove some more autopath while waiting for translations Modified: pypy/dist/pypy/objspace/test/test_descriptor.py ============================================================================== --- pypy/dist/pypy/objspace/test/test_descriptor.py (original) +++ pypy/dist/pypy/objspace/test/test_descriptor.py Fri Mar 2 13:51:40 2007 @@ -1,4 +1,3 @@ -import autopath class AppTest_Descriptor: Modified: pypy/dist/pypy/objspace/test/test_traceobjspace.py ============================================================================== --- pypy/dist/pypy/objspace/test/test_traceobjspace.py (original) +++ pypy/dist/pypy/objspace/test/test_traceobjspace.py Fri Mar 2 13:51:40 2007 @@ -1,4 +1,3 @@ -import autopath from pypy.objspace import trace from pypy.tool import pydis from pypy.interpreter import gateway From bea at codespeak.net Fri Mar 2 13:55:39 2007 From: bea at codespeak.net (bea at codespeak.net) Date: Fri, 2 Mar 2007 13:55:39 +0100 (CET) Subject: [pypy-svn] r39670 - pypy/extradoc/publication Message-ID: <20070302125539.C735F10053@code0.codespeak.net> Author: bea Date: Fri Mar 2 13:55:38 2007 New Revision: 39670 Removed: pypy/extradoc/publication/limerick_pypypaper_200701.pdf pypy/extradoc/publication/pypy-ieee_janfeb2007.pdf Log: removed files From mwh at codespeak.net Fri Mar 2 14:04:35 2007 From: mwh at codespeak.net (mwh at codespeak.net) Date: Fri, 2 Mar 2007 14:04:35 +0100 (CET) Subject: [pypy-svn] r39671 - in pypy/dist/pypy: config doc/config Message-ID: <20070302130435.9A06C1006E@code0.codespeak.net> Author: mwh Date: Fri Mar 2 14:04:32 2007 New Revision: 39671 Added: pypy/dist/pypy/doc/config/translation.backendopt.none.txt Modified: pypy/dist/pypy/config/translationoption.py Log: add a config option for turning off backend optimizations. Modified: pypy/dist/pypy/config/translationoption.py ============================================================================== --- pypy/dist/pypy/config/translationoption.py (original) +++ pypy/dist/pypy/config/translationoption.py Fri Mar 2 14:04:32 2007 @@ -157,6 +157,14 @@ "Remove operations that look like 'raise AssertionError', " "which lets the C optimizer remove the asserts", default=False), + + BoolOption("none", + "Do not run any backend optimizations", + requires=[('translation.backendopt.inline', False), + ('translation.backendopt.inline_threshold', 0), + ('translation.backendopt.merge_if_blocks', False), + ('translation.backendopt.mallocs', False), + ('translation.backendopt.constfold', False)]) ]), OptionDescription("cli", "GenCLI options", [ Added: pypy/dist/pypy/doc/config/translation.backendopt.none.txt ============================================================================== --- (empty file) +++ pypy/dist/pypy/doc/config/translation.backendopt.none.txt Fri Mar 2 14:04:32 2007 @@ -0,0 +1 @@ +Do not run any backend optimizations. From mwh at codespeak.net Fri Mar 2 14:26:18 2007 From: mwh at codespeak.net (mwh at codespeak.net) Date: Fri, 2 Mar 2007 14:26:18 +0100 (CET) Subject: [pypy-svn] r39672 - pypy/dist/pypy/doc/config Message-ID: <20070302132618.9BD5A10074@code0.codespeak.net> Author: mwh Date: Fri Mar 2 14:26:17 2007 New Revision: 39672 Modified: pypy/dist/pypy/doc/config/translation.backendopt.mallocs.txt Log: fix a link Modified: pypy/dist/pypy/doc/config/translation.backendopt.mallocs.txt ============================================================================== --- pypy/dist/pypy/doc/config/translation.backendopt.mallocs.txt (original) +++ pypy/dist/pypy/doc/config/translation.backendopt.mallocs.txt Fri Mar 2 14:26:17 2007 @@ -24,6 +24,6 @@ own inlining rather than relying on the C compilers). For much more information about this and other optimizations you can -read section 4.1 of the `technical report on "Massive Parallelism and -Translation Aspects" -`__. +read section 4.1 of the technical report on "Massive Parallelism and +Translation Aspects" which you can find on the `Technical reports page +<../index-report.html>`__. From rxe at codespeak.net Fri Mar 2 14:32:58 2007 From: rxe at codespeak.net (rxe at codespeak.net) Date: Fri, 2 Mar 2007 14:32:58 +0100 (CET) Subject: [pypy-svn] r39673 - pypy/dist/pypy/translator/c/test Message-ID: <20070302133258.BB72A10074@code0.codespeak.net> Author: rxe Date: Fri Mar 2 14:32:51 2007 New Revision: 39673 Modified: pypy/dist/pypy/translator/c/test/test_newgc.py pypy/dist/pypy/translator/c/test/test_standalone.py Log: clean up tests for seg faulting dictionary Modified: pypy/dist/pypy/translator/c/test/test_newgc.py ============================================================================== --- pypy/dist/pypy/translator/c/test/test_newgc.py (original) +++ pypy/dist/pypy/translator/c/test/test_newgc.py Fri Mar 2 14:32:51 2007 @@ -860,7 +860,8 @@ res = fn() def test_dict_segfault(self): - py.test.skip("some gc collect failing - somehow") + " was segfaulting at one point see rev 39665 for fix and details " + class Element: pass @@ -872,7 +873,6 @@ for ii in elements: reverse[ii] = ii - # print reverse.get(ii, None) for jj in range(100): e = l[-1] @@ -881,8 +881,8 @@ def f(): for ii in range(100): - print ii dostuff() + return 0 fn = self.getcompiled(f) # the point is just not to segfault Modified: pypy/dist/pypy/translator/c/test/test_standalone.py ============================================================================== --- pypy/dist/pypy/translator/c/test/test_standalone.py (original) +++ pypy/dist/pypy/translator/c/test/test_standalone.py Fri Mar 2 14:32:51 2007 @@ -118,37 +118,3 @@ out = py.process.cmdexec("%s 500" % exe) assert int(out) == 500*501/2 - -def test_dict_segfault(): - py.test.skip('segfaults :(') - class Element: - pass - - elements = [Element() for ii in range(10000)] - - def dostuff(): - reverse = {} - l = elements[:] - - for ii in elements: - reverse[ii] = ii#Element() - - for jj in range(100): - e = l[-1] - del reverse[e] - l.remove(e) - - def f(args): - for ii in range(100): - dostuff() - return 0 - - t = TranslationContext() - t.config.translation.gc = 'framework' - t.buildannotator().build_types(f, [s_list_of_strings]) - t.buildrtyper().specialize() - - cbuilder = CStandaloneBuilder(t, f, t.config) - cbuilder.generate_source() - cbuilder.compile() - data = cbuilder.cmdexec('') From gbrandl at codespeak.net Fri Mar 2 14:41:00 2007 From: gbrandl at codespeak.net (gbrandl at codespeak.net) Date: Fri, 2 Mar 2007 14:41:00 +0100 (CET) Subject: [pypy-svn] r39675 - pypy/dist/pypy/objspace/std Message-ID: <20070302134100.A3F9610084@code0.codespeak.net> Author: gbrandl Date: Fri Mar 2 14:40:58 2007 New Revision: 39675 Modified: pypy/dist/pypy/objspace/std/listmultiobject.py Log: (gbrandl, cfbolz): Better name for empty list method. Modified: pypy/dist/pypy/objspace/std/listmultiobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/listmultiobject.py (original) +++ pypy/dist/pypy/objspace/std/listmultiobject.py Fri Mar 2 14:40:58 2007 @@ -251,7 +251,7 @@ return "RListImplementation(%s)" % (self.list_w, ) class EmptyListImplementation(ListImplementation): - def make_impl(self, w_item): + def make_list_with_one_item(self, w_item): space = self.space if space.config.objspace.std.withfastslice: return SliceTrackingListImplementation(space, [w_item]) @@ -284,13 +284,13 @@ raise IndexError def insert(self, i, w_item): - return self.make_impl(w_item) + return self.make_list_with_one_item(w_item) def add(self, other): return other.copy() def append(self, w_item): - return self.make_impl(w_item) + return self.make_list_with_one_item(w_item) def extend(self, other): return other.copy() From afayolle at codespeak.net Fri Mar 2 14:47:20 2007 From: afayolle at codespeak.net (afayolle at codespeak.net) Date: Fri, 2 Mar 2007 14:47:20 +0100 (CET) Subject: [pypy-svn] r39676 - pypy/dist/pypy/module/recparser Message-ID: <20070302134720.02BF51006E@code0.codespeak.net> Author: afayolle Date: Fri Mar 2 14:47:18 2007 New Revision: 39676 Modified: pypy/dist/pypy/module/recparser/__init__.py pypy/dist/pypy/module/recparser/app_class.py Log: expose ASTVisitor in parser module Modified: pypy/dist/pypy/module/recparser/__init__.py ============================================================================== --- pypy/dist/pypy/module/recparser/__init__.py (original) +++ pypy/dist/pypy/module/recparser/__init__.py Fri Mar 2 14:47:18 2007 @@ -17,6 +17,7 @@ appleveldefs = { 'ParserError' : 'app_class.ParserError', + 'ASTVisitor': 'app_class.ASTVisitor', } interpleveldefs = { '__name__' : '(space.wrap("parser"))', Modified: pypy/dist/pypy/module/recparser/app_class.py ============================================================================== --- pypy/dist/pypy/module/recparser/app_class.py (original) +++ pypy/dist/pypy/module/recparser/app_class.py Fri Mar 2 14:47:18 2007 @@ -6,3 +6,180 @@ """Class ParserError Exception class for parser errors (I assume). """ + +class ASTVisitor(object): + """This is a visitor base class used to provide the visit + method in replacement of the former visitor.visit = walker.dispatch + It could also use to identify base type for visit arguments of AST nodes + """ + + def default(self, node): + for child in node.getChildNodes(): + child.accept(self) + return node + + def visitExpression(self, node): + return self.default(node) + + def visitEmptyNode(self, node): + return self.default(node) + + + def visitAbstractFunction(self, node): + return self.default( node ) + def visitAbstractTest(self, node): + return self.default( node ) + def visitAdd(self, node): + return self.default( node ) + def visitAnd(self, node): + return self.default( node ) + def visitAssAttr(self, node): + return self.default( node ) + def visitAssList(self, node): + return self.default( node ) + def visitAssName(self, node): + return self.default( node ) + def visitAssSeq(self, node): + return self.default( node ) + def visitAssTuple(self, node): + return self.default( node ) + def visitAssert(self, node): + return self.default( node ) + def visitAssign(self, node): + return self.default( node ) + def visitAugAssign(self, node): + return self.default( node ) + def visitBackquote(self, node): + return self.default( node ) + def visitBinaryOp(self, node): + return self.default( node ) + def visitBitOp(self, node): + return self.default( node ) + def visitBitand(self, node): + return self.default( node ) + def visitBitor(self, node): + return self.default( node ) + def visitBitxor(self, node): + return self.default( node ) + def visitBreak(self, node): + return self.default( node ) + def visitCallFunc(self, node): + return self.default( node ) + def visitClass(self, node): + return self.default( node ) + def visitCompare(self, node): + return self.default( node ) + def visitCondExpr(self, node): + return self.default( node ) + def visitConst(self, node): + return self.default( node ) + def visitContinue(self, node): + return self.default( node ) + def visitDecorators(self, node): + return self.default( node ) + def visitDict(self, node): + return self.default( node ) + def visitDiscard(self, node): + return self.default( node ) + def visitDiv(self, node): + return self.default( node ) + def visitEllipsis(self, node): + return self.default( node ) + def visitExec(self, node): + return self.default( node ) + def visitFloorDiv(self, node): + return self.default( node ) + def visitFor(self, node): + return self.default( node ) + def visitFrom(self, node): + return self.default( node ) + def visitFunction(self, node): + return self.default( node ) + def visitGenExpr(self, node): + return self.default( node ) + def visitGenExprFor(self, node): + return self.default( node ) + def visitGenExprIf(self, node): + return self.default( node ) + def visitGenExprInner(self, node): + return self.default( node ) + def visitGetattr(self, node): + return self.default( node ) + def visitGlobal(self, node): + return self.default( node ) + def visitIf(self, node): + return self.default( node ) + def visitImport(self, node): + return self.default( node ) + def visitInvert(self, node): + return self.default( node ) + def visitKeyword(self, node): + return self.default( node ) + def visitLambda(self, node): + return self.default( node ) + def visitLeftShift(self, node): + return self.default( node ) + def visitList(self, node): + return self.default( node ) + def visitListComp(self, node): + return self.default( node ) + def visitListCompFor(self, node): + return self.default( node ) + def visitListCompIf(self, node): + return self.default( node ) + def visitMod(self, node): + return self.default( node ) + def visitModule(self, node): + return self.default( node ) + def visitMul(self, node): + return self.default( node ) + def visitName(self, node): + return self.default( node ) + def visitNoneConst(self, node): + return self.default( node ) + def visitNot(self, node): + return self.default( node ) + def visitOr(self, node): + return self.default( node ) + def visitPass(self, node): + return self.default( node ) + def visitPower(self, node): + return self.default( node ) + def visitPrint(self, node): + return self.default( node ) + def visitPrintnl(self, node): + return self.default( node ) + def visitRaise(self, node): + return self.default( node ) + def visitReturn(self, node): + return self.default( node ) + def visitRightShift(self, node): + return self.default( node ) + def visitSlice(self, node): + return self.default( node ) + def visitSliceobj(self, node): + return self.default( node ) + def visitStmt(self, node): + return self.default( node ) + def visitSub(self, node): + return self.default( node ) + def visitSubscript(self, node): + return self.default( node ) + def visitTryExcept(self, node): + return self.default( node ) + def visitTryFinally(self, node): + return self.default( node ) + def visitTuple(self, node): + return self.default( node ) + def visitUnaryAdd(self, node): + return self.default( node ) + def visitUnaryOp(self, node): + return self.default( node ) + def visitUnarySub(self, node): + return self.default( node ) + def visitWhile(self, node): + return self.default( node ) + def visitWith(self, node): + return self.default( node ) + def visitYield(self, node): + return self.default( node ) From arigo at codespeak.net Fri Mar 2 14:54:33 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 2 Mar 2007 14:54:33 +0100 (CET) Subject: [pypy-svn] r39677 - pypy/dist/pypy/module/readline Message-ID: <20070302135433.9469A10113@code0.codespeak.net> Author: arigo Date: Fri Mar 2 14:54:30 2007 New Revision: 39677 Modified: pypy/dist/pypy/module/readline/c_readline.py Log: (hpk, arigo) Add history to the pypy-c prompt. Modified: pypy/dist/pypy/module/readline/c_readline.py ============================================================================== --- pypy/dist/pypy/module/readline/c_readline.py (original) +++ pypy/dist/pypy/module/readline/c_readline.py Fri Mar 2 14:54:30 2007 @@ -9,7 +9,7 @@ # class CConfig: _header_ = "" - _includes_ = ["readline/readline.h"] + _includes_ = ["readline/readline.h", "readline/history.h"] readline = Library('readline') cconfig = configure(CConfig) @@ -27,11 +27,27 @@ c_rl_initialize.argtypes = [] c_rl_initialize.restype = None +# void using_history(void) +c_using_history = libreadline.using_history +c_using_history.argtypes = [] +c_using_history.restype = None + +# void add_history(const char *) +c_add_history = libreadline.add_history +c_add_history.argtypes = [c_char_p] +c_add_history.restype = None + #------------------------------------------------------------ # special initialization of readline +class ReadlineState(object): + lastline = "" # XXX possibly temporary hack +readlinestate = ReadlineState() + def setup_readline(space, w_module): + c_using_history() + # XXX CPython initializes more stuff here c_rl_initialize() # install sys.__raw_input__, a hook that will be used by raw_input() space.setitem(space.sys.w_dict, space.wrap('__raw_input__'), @@ -41,6 +57,10 @@ res = c_readline(prompt) if res is None: raise OperationError(space.w_EOFError, space.w_None) + if res and res != readlinestate.lastline: + readlinestate.lastline = res + c_add_history(res) return space.wrap(res) + readline_func.unwrap_spec = [ObjSpace, str] app_readline_func = interp2app(readline_func) From santagada at codespeak.net Fri Mar 2 14:58:26 2007 From: santagada at codespeak.net (santagada at codespeak.net) Date: Fri, 2 Mar 2007 14:58:26 +0100 (CET) Subject: [pypy-svn] r39678 - in pypy/dist/pypy/lang/js: . test/ecma Message-ID: <20070302135826.052071013C@code0.codespeak.net> Author: santagada Date: Fri Mar 2 14:58:24 2007 New Revision: 39678 Modified: pypy/dist/pypy/lang/js/interpreter.py pypy/dist/pypy/lang/js/jsobj.py pypy/dist/pypy/lang/js/test/ecma/shell.js Log: new shift operators and math.pow Modified: pypy/dist/pypy/lang/js/interpreter.py ============================================================================== --- pypy/dist/pypy/lang/js/interpreter.py (original) +++ pypy/dist/pypy/lang/js/interpreter.py Fri Mar 2 14:58:24 2007 @@ -3,6 +3,7 @@ from pypy.lang.js.jsparser import parse, parse_bytecode from pypy.lang.js.jsobj import * from pypy.rlib.parsing.ebnfparse import Symbol, Nonterminal +from pypy.rlib.rarithmetic import r_uint class Node(object): opcode = None @@ -156,6 +157,9 @@ def floorjs(ctx, args, this): return W_Number(math.floor(args[0].ToNumber())) +def powjs(ctx, args, this): + return W_Number(math.pow(args[0].ToNumber(), args[1].ToNumber())) + def versionjs(ctx, args, this): return w_Undefined @@ -187,6 +191,7 @@ w_math.Put('__proto__', w_ObjPrototype) w_math.Put('abs', W_Builtin(absjs, Class='function')) w_math.Put('floor', W_Builtin(floorjs, Class='function')) + w_math.Put('pow', W_Builtin(powjs, Class='function')) w_math.Put('E', W_Number(math.e)) w_math.Put('PI', W_Number(math.pi)) @@ -351,6 +356,7 @@ r7 = None else: r7 = r6 + retval = r3.Call(ctx=ctx, args=r2.get_args(), this=r7) return retval @@ -482,6 +488,30 @@ s4 = self.right.eval(ctx).GetValue() return s4 +class Ursh(BinaryComparisonOp): + opcode = 'URSH' + + def decision(self, ctx, op1, op2): + a = op1.ToInt32() + b = op2.ToInt32() + return W_Number(r_uint(a) >> (r_uint(b) & 0x1F)) + +class Rsh(BinaryComparisonOp): + opcode = 'RSH' + + def decision(self, ctx, op1, op2): + a = op1.ToInt32() + b = op2.ToInt32() + return W_Number(a >> int(r_uint(b) & 0x1F)) + +class Lsh(BinaryComparisonOp): + opcode = 'LSH' + + def decision(self, ctx, op1, op2): + a = op1.ToInt32() + b = op2.ToInt32() + return W_Number(a << int(r_uint(b) & 0x1F)) + class Ge(BinaryComparisonOp): opcode = 'GE' @@ -842,6 +872,7 @@ ctx.variable.Put(var.name, w_Undefined) for fun in self.func_decl: ctx.variable.Put(fun.name, fun.eval(ctx)) + node = self Modified: pypy/dist/pypy/lang/js/jsobj.py ============================================================================== --- pypy/dist/pypy/lang/js/jsobj.py (original) +++ pypy/dist/pypy/lang/js/jsobj.py Fri Mar 2 14:58:24 2007 @@ -395,6 +395,12 @@ return 'number' def ToInt32(self): + strval = str(self.floatval) + if strval == str(NaN) or \ + strval == str(Infinity) or \ + strval == str(-Infinity): + return 0 + return int(self.floatval) class W_List(W_Root): Modified: pypy/dist/pypy/lang/js/test/ecma/shell.js ============================================================================== --- pypy/dist/pypy/lang/js/test/ecma/shell.js (original) +++ pypy/dist/pypy/lang/js/test/ecma/shell.js Fri Mar 2 14:58:24 2007 @@ -50,7 +50,7 @@ var PASSED = " PASSED!" var FAILED = " FAILED! expected: "; -var DEBUG = true; +var DEBUG = false; var DESCRIPTION; var EXPECTED; @@ -218,7 +218,7 @@ } function writeHeaderToLog( string ) { - print( string ); + // print( string ); } /* end of print functions */ From santagada at codespeak.net Fri Mar 2 15:04:09 2007 From: santagada at codespeak.net (santagada at codespeak.net) Date: Fri, 2 Mar 2007 15:04:09 +0100 (CET) Subject: [pypy-svn] r39679 - pypy/dist/pypy/lang/js Message-ID: <20070302140409.9127B10113@code0.codespeak.net> Author: santagada Date: Fri Mar 2 15:04:05 2007 New Revision: 39679 Modified: pypy/dist/pypy/lang/js/interpreter.py Log: the math here is wrong, waiting for support from rlib Modified: pypy/dist/pypy/lang/js/interpreter.py ============================================================================== --- pypy/dist/pypy/lang/js/interpreter.py (original) +++ pypy/dist/pypy/lang/js/interpreter.py Fri Mar 2 15:04:05 2007 @@ -494,7 +494,7 @@ def decision(self, ctx, op1, op2): a = op1.ToInt32() b = op2.ToInt32() - return W_Number(r_uint(a) >> (r_uint(b) & 0x1F)) + return W_Number(int(r_uint(a) >> (r_uint(b) & 0x1F))) class Rsh(BinaryComparisonOp): opcode = 'RSH' From arigo at codespeak.net Fri Mar 2 15:10:44 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 2 Mar 2007 15:10:44 +0100 (CET) Subject: [pypy-svn] r39680 - in pypy/dist/pypy: rlib rlib/test rpython/test Message-ID: <20070302141044.A736A10113@code0.codespeak.net> Author: arigo Date: Fri Mar 2 15:10:42 2007 New Revision: 39680 Modified: pypy/dist/pypy/rlib/rarithmetic.py pypy/dist/pypy/rlib/test/test_rarithmetic.py pypy/dist/pypy/rpython/test/test_rfloat.py Log: Support for direct casts between float and r_uint. Actually worked already during translation, but not on top of CPython. Modified: pypy/dist/pypy/rlib/rarithmetic.py ============================================================================== --- pypy/dist/pypy/rlib/rarithmetic.py (original) +++ pypy/dist/pypy/rlib/rarithmetic.py Fri Mar 2 15:10:42 2007 @@ -267,6 +267,8 @@ class signed_int(base_int): SIGNED = True def __new__(klass, val=0): + if type(val) is float: + val = long(val) if val > klass.MASK>>1 or val < -(klass.MASK>>1)-1: raise OverflowError("%s does not fit in signed %d-bit integer"%(val, klass.BITS)) if val < 0: @@ -277,6 +279,8 @@ class unsigned_int(base_int): SIGNED = False def __new__(klass, val=0): + if type(val) is float: + val = long(val) return super(unsigned_int, klass).__new__(klass, val & klass.MASK) typemap = {} Modified: pypy/dist/pypy/rlib/test/test_rarithmetic.py ============================================================================== --- pypy/dist/pypy/rlib/test/test_rarithmetic.py (original) +++ pypy/dist/pypy/rlib/test/test_rarithmetic.py Fri Mar 2 15:10:42 2007 @@ -139,6 +139,15 @@ res = res & mask assert res == cmp + def test_from_float(self): + assert r_uint(2.3) == 2 + assert r_uint(sys.maxint * 1.234) == long(sys.maxint * 1.234) + + def test_to_float(self): + assert float(r_uint(2)) == 2.0 + val = long(sys.maxint * 1.234) + assert float(r_uint(val)) == float(val) + def test_mixed_types(): types = [r_uint, r_ulonglong] for left in types: Modified: pypy/dist/pypy/rpython/test/test_rfloat.py ============================================================================== --- pypy/dist/pypy/rpython/test/test_rfloat.py (original) +++ pypy/dist/pypy/rpython/test/test_rfloat.py Fri Mar 2 15:10:42 2007 @@ -1,6 +1,8 @@ +import sys from pypy.translator.translator import TranslationContext from pypy.rpython.test import snippet from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin +from pypy.rlib.rarithmetic import r_uint class TestSnippet(object): @@ -58,6 +60,25 @@ res = self.interpret(fn, [2.34]) assert res == fn(2.34) + def test_to_r_uint(self): + def fn(x): + return r_uint(x) + + res = self.interpret(fn, [12.34]) + assert res == 12 + bigval = sys.maxint * 1.234 + res = self.interpret(fn, [bigval]) + assert long(res) == long(bigval) + + def test_from_r_uint(self): + def fn(n): + return float(r_uint(n)) / 2 + + res = self.interpret(fn, [41]) + assert res == 20.5 + res = self.interpret(fn, [-9]) + assert res == 0.5 * ((sys.maxint+1)*2 - 9) + class TestLLtype(BaseTestRfloat, LLRtypeMixin): From hpk at codespeak.net Fri Mar 2 15:12:37 2007 From: hpk at codespeak.net (hpk at codespeak.net) Date: Fri, 2 Mar 2007 15:12:37 +0100 (CET) Subject: [pypy-svn] r39681 - in pypy/dist/pypy/objspace/std: . test Message-ID: <20070302141237.4D4E710121@code0.codespeak.net> Author: hpk Date: Fri Mar 2 15:12:33 2007 New Revision: 39681 Removed: pypy/dist/pypy/objspace/std/autopath.py pypy/dist/pypy/objspace/std/test/autopath.py Modified: pypy/dist/pypy/objspace/std/test/test_boolobject.py pypy/dist/pypy/objspace/std/test/test_complexobject.py pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py pypy/dist/pypy/objspace/std/test/test_dictobject.py pypy/dist/pypy/objspace/std/test/test_dictproxy.py pypy/dist/pypy/objspace/std/test/test_dictstrobject.py pypy/dist/pypy/objspace/std/test/test_floatobject.py pypy/dist/pypy/objspace/std/test/test_instmethobject.py pypy/dist/pypy/objspace/std/test/test_intobject.py pypy/dist/pypy/objspace/std/test/test_iterobject.py pypy/dist/pypy/objspace/std/test/test_listmultiobject.py pypy/dist/pypy/objspace/std/test/test_listobject.py pypy/dist/pypy/objspace/std/test/test_longobject.py pypy/dist/pypy/objspace/std/test/test_multimethod.py pypy/dist/pypy/objspace/std/test/test_noneobject.py pypy/dist/pypy/objspace/std/test/test_rangeobject.py pypy/dist/pypy/objspace/std/test/test_set.py pypy/dist/pypy/objspace/std/test/test_sliceobject.py pypy/dist/pypy/objspace/std/test/test_smallintobject.py pypy/dist/pypy/objspace/std/test/test_stdobjspace.py pypy/dist/pypy/objspace/std/test/test_stringformat.py pypy/dist/pypy/objspace/std/test/test_stringobject.py pypy/dist/pypy/objspace/std/test/test_strjoinobject.py pypy/dist/pypy/objspace/std/test/test_strsliceobject.py pypy/dist/pypy/objspace/std/test/test_strutil.py pypy/dist/pypy/objspace/std/test/test_tupleobject.py pypy/dist/pypy/objspace/std/test/test_typeobject.py pypy/dist/pypy/objspace/std/test/test_unicodeobject.py pypy/dist/pypy/objspace/std/test/test_userobject.py Log: removing autopath from std object space and fixing an escaping issue in test_complexobject.py (hopefully) Modified: pypy/dist/pypy/objspace/std/test/test_boolobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_boolobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_boolobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath Modified: pypy/dist/pypy/objspace/std/test/test_complexobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_complexobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_complexobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath import py from pypy.objspace.std import complexobject as cobj from pypy.objspace.std import complextype as cobjtype @@ -60,7 +59,13 @@ class AppTestAppComplexTest: def setup_class(cls): - cls.w_helper = cls.space.appexec([], "():\n import sys\n sys.path.append('%s')\n import helper\n return helper" % (str(py.magic.autopath().dirpath()).replace('\\', '\\\\'), )) + cls.w_helper = cls.space.appexec([], """ + (): + import sys + sys.path.append(%r) + import helper + return helper + """ % (str(py.magic.autopath().dirpath()))) def test_div(self): h = self.helper Modified: pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath from pypy.interpreter.error import OperationError from pypy.objspace.std.dictmultiobject import \ W_DictMultiObject, setitem__DictMulti_ANY_ANY, getitem__DictMulti_ANY, \ Modified: pypy/dist/pypy/objspace/std/test/test_dictobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_dictobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_dictobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath from pypy.objspace.std.dictobject import W_DictObject from pypy.conftest import gettestobjspace Modified: pypy/dist/pypy/objspace/std/test/test_dictproxy.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_dictproxy.py (original) +++ pypy/dist/pypy/objspace/std/test/test_dictproxy.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath class AppTestUserObject: Modified: pypy/dist/pypy/objspace/std/test/test_dictstrobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_dictstrobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_dictstrobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath from pypy.objspace.std.dictstrobject import W_DictStrObject, setitem__DictStr_ANY_ANY, getitem__DictStr_ANY from pypy.conftest import gettestobjspace from pypy.objspace.std.test import test_dictobject Modified: pypy/dist/pypy/objspace/std/test/test_floatobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_floatobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_floatobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath from pypy.objspace.std import floatobject as fobj from pypy.objspace.std.objspace import FailedToImplement import py Modified: pypy/dist/pypy/objspace/std/test/test_instmethobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_instmethobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_instmethobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath # NB. instmethobject.py has been removed, # but the following tests still make sense Modified: pypy/dist/pypy/objspace/std/test/test_intobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_intobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_intobject.py Fri Mar 2 15:12:33 2007 @@ -1,5 +1,4 @@ import sys -import autopath from pypy.objspace.std import intobject as iobj from pypy.objspace.std.objspace import FailedToImplement from pypy.rlib.rarithmetic import r_uint Modified: pypy/dist/pypy/objspace/std/test/test_iterobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_iterobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_iterobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath from pypy.objspace.std.iterobject import W_SeqIterObject from pypy.interpreter.error import OperationError Modified: pypy/dist/pypy/objspace/std/test/test_listmultiobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_listmultiobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_listmultiobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath from pypy.interpreter.error import OperationError from pypy.objspace.std.listmultiobject import W_ListMultiObject, \ SliceTrackingListImplementation Modified: pypy/dist/pypy/objspace/std/test/test_listobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_listobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_listobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,4 @@ -import autopath, random +import random from pypy.objspace.std.listobject import W_ListObject from pypy.interpreter.error import OperationError Modified: pypy/dist/pypy/objspace/std/test/test_longobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_longobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_longobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath import py import sys from pypy.objspace.std import longobject as lobj Modified: pypy/dist/pypy/objspace/std/test/test_multimethod.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_multimethod.py (original) +++ pypy/dist/pypy/objspace/std/test/test_multimethod.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath from py.test import raises from pypy.objspace.std import multimethod Modified: pypy/dist/pypy/objspace/std/test/test_noneobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_noneobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_noneobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath Modified: pypy/dist/pypy/objspace/std/test/test_rangeobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_rangeobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_rangeobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,4 @@ -import autopath, py +import py from pypy.conftest import gettestobjspace Modified: pypy/dist/pypy/objspace/std/test/test_set.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_set.py (original) +++ pypy/dist/pypy/objspace/std/test/test_set.py Fri Mar 2 15:12:33 2007 @@ -7,7 +7,6 @@ This file just contains some basic tests that make sure, the implementation is not too wrong. """ -import autopath import py.test from pypy.objspace.std.setobject import W_SetObject, W_FrozensetObject from pypy.objspace.std.setobject import _initialize_set Modified: pypy/dist/pypy/objspace/std/test/test_sliceobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_sliceobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_sliceobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath class TestW_SliceObject: Modified: pypy/dist/pypy/objspace/std/test/test_smallintobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_smallintobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_smallintobject.py Fri Mar 2 15:12:33 2007 @@ -1,5 +1,4 @@ import sys, py -import autopath #from pypy.objspace.std.model import WITHSMALLINT #if not WITHSMALLINT: Modified: pypy/dist/pypy/objspace/std/test/test_stdobjspace.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_stdobjspace.py (original) +++ pypy/dist/pypy/objspace/std/test/test_stdobjspace.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath from pypy.interpreter.error import OperationError Modified: pypy/dist/pypy/objspace/std/test/test_stringformat.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_stringformat.py (original) +++ pypy/dist/pypy/objspace/std/test/test_stringformat.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath class AppTestStringObjectWithDict: Modified: pypy/dist/pypy/objspace/std/test/test_stringobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_stringobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_stringobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath from pypy.objspace.std import stringobject from pypy.objspace.std.stringobject import W_StringObject Modified: pypy/dist/pypy/objspace/std/test/test_strjoinobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_strjoinobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_strjoinobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,4 @@ -import autopath, py +import py from pypy.objspace.std.test import test_stringobject from pypy.conftest import gettestobjspace Modified: pypy/dist/pypy/objspace/std/test/test_strsliceobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_strsliceobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_strsliceobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,4 @@ -import autopath, py +import py from pypy.objspace.std.test import test_stringobject from pypy.conftest import gettestobjspace Modified: pypy/dist/pypy/objspace/std/test/test_strutil.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_strutil.py (original) +++ pypy/dist/pypy/objspace/std/test/test_strutil.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath import py, random from pypy.objspace.std.strutil import * Modified: pypy/dist/pypy/objspace/std/test/test_tupleobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_tupleobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_tupleobject.py Fri Mar 2 15:12:33 2007 @@ -1,5 +1,4 @@ #from __future__ import nested_scopes -import autopath from pypy.objspace.std.tupleobject import W_TupleObject from pypy.interpreter.error import OperationError Modified: pypy/dist/pypy/objspace/std/test/test_typeobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_typeobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_typeobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath from pypy.objspace.std.objspace import * from pypy.objspace.std.stdtypedef import * Modified: pypy/dist/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_unicodeobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,4 @@ -import autopath, sys +import sys class AppTestUnicodeStringStdOnly: Modified: pypy/dist/pypy/objspace/std/test/test_userobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_userobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_userobject.py Fri Mar 2 15:12:33 2007 @@ -1,4 +1,3 @@ -import autopath class AppTestUserObject: From antocuni at codespeak.net Fri Mar 2 15:12:59 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Fri, 2 Mar 2007 15:12:59 +0100 (CET) Subject: [pypy-svn] r39682 - pypy/dist/pypy/annotation Message-ID: <20070302141259.7967610121@code0.codespeak.net> Author: antocuni Date: Fri Mar 2 15:12:58 2007 New Revision: 39682 Modified: pypy/dist/pypy/annotation/builtin.py Log: (antocuni, pedronis) try to make the memory used by the annotator not linear in the length of the range(). Modified: pypy/dist/pypy/annotation/builtin.py ============================================================================== --- pypy/dist/pypy/annotation/builtin.py (original) +++ pypy/dist/pypy/annotation/builtin.py Fri Mar 2 15:12:58 2007 @@ -65,7 +65,7 @@ if step == 0: raise Exception, "range() with step zero" if s_start.is_constant() and s_stop.is_constant(): - if len(range(s_start.const, s_stop.const, step)) == 0: + if len(xrange(s_start.const, s_stop.const, step)) == 0: empty = True if empty: s_item = s_ImpossibleValue From cfbolz at codespeak.net Fri Mar 2 15:18:48 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Fri, 2 Mar 2007 15:18:48 +0100 (CET) Subject: [pypy-svn] r39683 - pypy/dist/pypy/doc/config Message-ID: <20070302141848.8F74510120@code0.codespeak.net> Author: cfbolz Date: Fri Mar 2 15:18:46 2007 New Revision: 39683 Added: pypy/dist/pypy/doc/config/objspace.std.withsmartresizablelist.txt Log: (cfbolz, gbrandl): add documentation for the new option Added: pypy/dist/pypy/doc/config/objspace.std.withsmartresizablelist.txt ============================================================================== --- (empty file) +++ pypy/dist/pypy/doc/config/objspace.std.withsmartresizablelist.txt Fri Mar 2 15:18:46 2007 @@ -0,0 +1,4 @@ +Enable a list implementation that overallocates only O(sqrt(n)) elements +instead of O(n) elements. See "Resizable Arrays in Optimal time and Space" +Brodnik, Carlsson, Demaine, Munro, Sedgewick, 1999 + From mwh at codespeak.net Fri Mar 2 15:20:16 2007 From: mwh at codespeak.net (mwh at codespeak.net) Date: Fri, 2 Mar 2007 15:20:16 +0100 (CET) Subject: [pypy-svn] r39684 - pypy/dist/pypy/doc Message-ID: <20070302142016.707941013F@code0.codespeak.net> Author: mwh Date: Fri Mar 2 15:20:13 2007 New Revision: 39684 Modified: pypy/dist/pypy/doc/faq.txt Log: reword the first two FAQ entries Modified: pypy/dist/pypy/doc/faq.txt ============================================================================== --- pypy/dist/pypy/doc/faq.txt (original) +++ pypy/dist/pypy/doc/faq.txt Fri Mar 2 15:20:13 2007 @@ -12,12 +12,16 @@ What is PyPy? ------------- -PyPy is both a Python reimplementation and a framework to implement -interpreters and virtual machines for programming languages, -especially dynamic ones. PyPy tries to find new answers about ease of -creation, flexibility, maintainability and speed trade-offs for -language implementations. For further details see our `goal and -architecture document`_ . +PyPy is both: + + - a reimplementation of Python in Python, and + + - a framework for implementing interpreters and virtual machines for + programming languages, especially dynamic languages. + +PyPy tries to find new answers about ease of creation, flexibility, +maintainability and speed trade-offs for language implementations. +For further details see our `goal and architecture document`_ . .. _`goal and architecture document`: architecture.html @@ -28,11 +32,16 @@ Is PyPy a drop in replacement for CPython? ------------------------------------------ -Not completely, at least not yet. There are various areas where PyPy is lacking, such as -threading_ and `extension modules`_. The language features (including builtin -types and functions) are very complete and well tested, though. This means that -a project not using many extension modules can probably directly use PyPy. A -project using extension modules might get some problems, though. +Not completely, at least not yet. + +The mostly likely stumbling block for any given project is support for +`extension modules`_. PyPy supports a small but continually growing +number of extension modules, so far mostly those found in the standard +library. The `threading` support is also not perfectly complete. + +The language features (including builtin types and functions) are very +complete and well tested, so if your project does not use many +extension modules there is a good chance that it will work with PyPy. -------------------------------- On what platforms does PyPy run? From cfbolz at codespeak.net Fri Mar 2 15:24:51 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Fri, 2 Mar 2007 15:24:51 +0100 (CET) Subject: [pypy-svn] r39685 - in pypy/dist/pypy: config objspace/std objspace/std/test Message-ID: <20070302142451.031A910147@code0.codespeak.net> Author: cfbolz Date: Fri Mar 2 15:24:42 2007 New Revision: 39685 Added: pypy/dist/pypy/objspace/std/smartresizablelist.py Modified: pypy/dist/pypy/config/pypyoption.py pypy/dist/pypy/objspace/std/listmultiobject.py pypy/dist/pypy/objspace/std/test/test_listmultiobject.py Log: (cfbolz, gbrandl): implement list overallocation with O(sqrt(n)) elements. Modified: pypy/dist/pypy/config/pypyoption.py ============================================================================== --- pypy/dist/pypy/config/pypyoption.py (original) +++ pypy/dist/pypy/config/pypyoption.py Fri Mar 2 15:24:42 2007 @@ -182,6 +182,10 @@ "make list slicing lazy", default=False, requires=[("objspace.std.withmultilist", True)]), + BoolOption("withsmartresizablelist", + "only overallocate O(sqrt(n)) elements for lists", + default=False, + requires=[("objspace.std.withmultilist", True)]), BoolOption("optimized_int_add", "special case the addition of two integers in BINARY_ADD", default=False), Modified: pypy/dist/pypy/objspace/std/listmultiobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/listmultiobject.py (original) +++ pypy/dist/pypy/objspace/std/listmultiobject.py Fri Mar 2 15:24:42 2007 @@ -178,6 +178,12 @@ def make_implementation(self, list_w): space = self.space + if space.config.objspace.std.withsmartresizablelist: + from pypy.objspace.std.smartresizablelist import \ + SmartResizableListImplementation + impl = SmartResizableListIm