[pypy-svn] r74043 - in pypy/trunk/pypy: annotation translator/backendopt

benjamin at codespeak.net benjamin at codespeak.net
Sun Apr 25 03:18:35 CEST 2010


Author: benjamin
Date: Sun Apr 25 03:18:33 2010
New Revision: 74043

Modified:
   pypy/trunk/pypy/annotation/binaryop.py
   pypy/trunk/pypy/annotation/model.py
   pypy/trunk/pypy/annotation/unaryop.py
   pypy/trunk/pypy/translator/backendopt/support.py
Log:
use builtin sets

Modified: pypy/trunk/pypy/annotation/binaryop.py
==============================================================================
--- pypy/trunk/pypy/annotation/binaryop.py	(original)
+++ pypy/trunk/pypy/annotation/binaryop.py	Sun Apr 25 03:18:33 2010
@@ -14,7 +14,7 @@
 from pypy.annotation.model import SomeExternalObject, SomeWeakRef
 from pypy.annotation.model import SomeAddress, SomeTypedAddressAccess
 from pypy.annotation.model import SomeSingleFloat
-from pypy.annotation.model import unionof, UnionError, set, missing_operation
+from pypy.annotation.model import unionof, UnionError, missing_operation
 from pypy.annotation.model import isdegenerated, TLS
 from pypy.annotation.model import read_can_only_throw
 from pypy.annotation.model import add_knowntypedata, merge_knowntypedata

Modified: pypy/trunk/pypy/annotation/model.py
==============================================================================
--- pypy/trunk/pypy/annotation/model.py	(original)
+++ pypy/trunk/pypy/annotation/model.py	Sun Apr 25 03:18:33 2010
@@ -695,19 +695,6 @@
 # ____________________________________________________________
 # internal
 
-def setunion(d1, d2):
-    "Union of two sets represented as dictionaries."
-    d = d1.copy()
-    d.update(d2)
-    return d
-
-def set(it):
-    "Turn an iterable into a set."
-    d = {}
-    for x in it:
-        d[x] = True
-    return d
-
 def commonbase(cls1, cls2):   # XXX single inheritance only  XXX hum
     l1 = inspect.getmro(cls1)
     l2 = inspect.getmro(cls2) 

Modified: pypy/trunk/pypy/annotation/unaryop.py
==============================================================================
--- pypy/trunk/pypy/annotation/unaryop.py	(original)
+++ pypy/trunk/pypy/annotation/unaryop.py	Sun Apr 25 03:18:33 2010
@@ -9,7 +9,7 @@
      SomeInstance, SomeBuiltin, SomeFloat, SomeIterator, SomePBC, \
      SomeExternalObject, SomeTypedAddressAccess, SomeAddress, \
      s_ImpossibleValue, s_Bool, s_None, \
-     unionof, set, missing_operation, add_knowntypedata, HarmlesslyBlocked, \
+     unionof, missing_operation, add_knowntypedata, HarmlesslyBlocked, \
      SomeGenericCallable, SomeWeakRef, SomeUnicodeString
 from pypy.annotation.bookkeeper import getbookkeeper
 from pypy.annotation import builtin

Modified: pypy/trunk/pypy/translator/backendopt/support.py
==============================================================================
--- pypy/trunk/pypy/translator/backendopt/support.py	(original)
+++ pypy/trunk/pypy/translator/backendopt/support.py	Sun Apr 25 03:18:33 2010
@@ -3,7 +3,7 @@
 from pypy.translator.simplify import get_graph
 from pypy.rpython.rmodel import inputconst 
 from pypy.tool.ansi_print import ansi_log
-from pypy.annotation.model import setunion, s_ImpossibleValue
+from pypy.annotation.model import s_ImpossibleValue
 from pypy.translator.unsimplify import split_block, copyvar, insert_empty_block
 from pypy.objspace.flow.model import Constant, Variable, SpaceOperation, c_last_exception
 from pypy.rpython.lltypesystem import lltype
@@ -152,17 +152,17 @@
     reachable = {}
     blocks = list(graph.iterblocks())
     for block in py.builtin.reversed(blocks): # this order should make the reuse path more likely
-        reach = {}
+        reach = set()
         scheduled = [block]
         while scheduled:
             current = scheduled.pop()
             for link in current.exits:
                 if link.target in reachable:
-                    reach[link.target] = True
-                    reach = setunion(reach, reachable[link.target])
+                    reach.add(link.target)
+                    reach = reach | reachable[link.target]
                     continue
                 if link.target not in reach:
-                    reach[link.target] = True
+                    reach.add(link.target)
                     scheduled.append(link.target)
         reachable[block] = reach
     return reachable



More information about the Pypy-commit mailing list