[pypy-svn] r7761 - pypy/trunk/src/pypy/annotation

mwh at codespeak.net mwh at codespeak.net
Mon Dec 6 17:01:15 CET 2004


Author: mwh
Date: Mon Dec  6 17:01:15 2004
New Revision: 7761

Modified:
   pypy/trunk/src/pypy/annotation/binaryop.py
Log:
Be a bit more cautious in (SomeTuple, SomeInteger).getitem().

Always do (SomePBC, SomePBC).union() the more efficient way round.


Modified: pypy/trunk/src/pypy/annotation/binaryop.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/binaryop.py	(original)
+++ pypy/trunk/src/pypy/annotation/binaryop.py	Mon Dec  6 17:01:15 2004
@@ -224,7 +224,10 @@
     
     def getitem((tup1, int2)):
         if int2.is_constant():
-            return tup1.items[int2.const]
+            try:
+                return tup1.items[int2.const]
+            except IndexError:
+                return SomeImpossibleValue()
         else:
             return unionof(*tup1.items)
 
@@ -282,6 +285,8 @@
     def union((pbc1, pbc2)):
         if isinstance(pbc1, SomeBuiltin) or isinstance(pbc2, SomeBuiltin):
             assert False, "merging builtin & PBC == BAD!"
+        if len(pbc2.prebuiltinstances) > len(pbc1.prebuiltinstances):
+            pbc1, pbc2 = pbc2, pbc1
         d = pbc1.prebuiltinstances.copy()
         for x, classdef in pbc2.prebuiltinstances.items():
             if x in d:



More information about the Pypy-commit mailing list