[pypy-svn] pypy default: Small tweak and optimization

amauryfa commits-noreply at bitbucket.org
Fri Mar 11 18:20:57 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r42520:2f23e4b02b21
Date: 2011-03-11 16:37 +0100
http://bitbucket.org/pypy/pypy/changeset/2f23e4b02b21/

Log:	Small tweak and optimization

diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py b/pypy/interpreter/astcompiler/tools/asdl_py.py
--- a/pypy/interpreter/astcompiler/tools/asdl_py.py
+++ b/pypy/interpreter/astcompiler/tools/asdl_py.py
@@ -378,8 +378,9 @@
 
     def make_init(self, name, fields):
         comma_fields = ", ".join(repr(field.name.value) for field in fields)
-        config = (name, comma_fields)
-        self.emit("_%s_field_unroller = unrolling_iterable([%s])" % config)
+        if fields:
+            config = (name, comma_fields)
+            self.emit("_%s_field_unroller = unrolling_iterable([%s])" % config)
         self.emit("def %s_init(space, w_self, __args__):" % (name,))
         self.emit("w_self = space.descr_self_interp_w(%s, w_self)" % (name,), 1)
         for field in fields:
@@ -399,7 +400,7 @@
             self.emit("i += 1", 3)
         else:
             self.emit("w_err = space.wrap(\"%s constructor takes no " \
-                          " arguments\")" % (name,), 2)
+                          "arguments\")" % (name,), 2)
             self.emit("raise OperationError(space.w_TypeError, w_err)", 2)
         self.emit("for field, w_value in kwargs_w.iteritems():", 1)
         self.emit("space.setattr(w_self, space.wrap(field), w_value)", 2)

diff --git a/pypy/interpreter/astcompiler/ast.py b/pypy/interpreter/astcompiler/ast.py
--- a/pypy/interpreter/astcompiler/ast.py
+++ b/pypy/interpreter/astcompiler/ast.py
@@ -4442,12 +4442,11 @@
 )
 Expr.typedef.acceptable_as_base_class = False
 
-_Pass_field_unroller = unrolling_iterable([])
 def Pass_init(space, w_self, __args__):
     w_self = space.descr_self_interp_w(Pass, w_self)
     args_w, kwargs_w = __args__.unpack()
     if args_w:
-        w_err = space.wrap("Pass constructor takes no  arguments")
+        w_err = space.wrap("Pass constructor takes no arguments")
         raise OperationError(space.w_TypeError, w_err)
     for field, w_value in kwargs_w.iteritems():
         space.setattr(w_self, space.wrap(field), w_value)
@@ -4460,12 +4459,11 @@
 )
 Pass.typedef.acceptable_as_base_class = False
 
-_Break_field_unroller = unrolling_iterable([])
 def Break_init(space, w_self, __args__):
     w_self = space.descr_self_interp_w(Break, w_self)
     args_w, kwargs_w = __args__.unpack()
     if args_w:
-        w_err = space.wrap("Break constructor takes no  arguments")
+        w_err = space.wrap("Break constructor takes no arguments")
         raise OperationError(space.w_TypeError, w_err)
     for field, w_value in kwargs_w.iteritems():
         space.setattr(w_self, space.wrap(field), w_value)
@@ -4478,12 +4476,11 @@
 )
 Break.typedef.acceptable_as_base_class = False
 
-_Continue_field_unroller = unrolling_iterable([])
 def Continue_init(space, w_self, __args__):
     w_self = space.descr_self_interp_w(Continue, w_self)
     args_w, kwargs_w = __args__.unpack()
     if args_w:
-        w_err = space.wrap("Continue constructor takes no  arguments")
+        w_err = space.wrap("Continue constructor takes no arguments")
         raise OperationError(space.w_TypeError, w_err)
     for field, w_value in kwargs_w.iteritems():
         space.setattr(w_self, space.wrap(field), w_value)
@@ -5769,12 +5766,11 @@
 )
 slice.typedef.acceptable_as_base_class = False
 
-_Ellipsis_field_unroller = unrolling_iterable([])
 def Ellipsis_init(space, w_self, __args__):
     w_self = space.descr_self_interp_w(Ellipsis, w_self)
     args_w, kwargs_w = __args__.unpack()
     if args_w:
-        w_err = space.wrap("Ellipsis constructor takes no  arguments")
+        w_err = space.wrap("Ellipsis constructor takes no arguments")
         raise OperationError(space.w_TypeError, w_err)
     for field, w_value in kwargs_w.iteritems():
         space.setattr(w_self, space.wrap(field), w_value)


More information about the Pypy-commit mailing list