Hi Amaury, On Tue, Sep 13, 2005 at 02:17:47PM +0200, Amaury Forgeot D Arc wrote: > While playing with the annotator/translator, I found > a strange test case.
The test as you reported it shows the intended behavior of DictDefs; what did you expect, i.e. what are you trying to achieve? Dicts and lists are a delicate part of the annotator because they are mutable objects. The annotator's goal here is to figure out what kind of objects will *ever* be put in the dict. It's the purpose of the DictDefs to record (as a side-effect) what is done with the dicts. > def test_dictdef(): > def1 = DictDef(None, SomeInteger(), SomeInteger()) > def2 = DictDef(None, SomeInteger(), SomeInteger()) > dic1 = SomeDict(def1) > dic2 = SomeDict(def2) > assert not dic1 == dic2 The two dicts are unrelated; the annotator thinks they come from different creation points. Until proven otherwise the two SomeDict()s represent two unrelated sets of possible run-time dictionaries. > x = unionof(dic1, dic2) This means that the two dicts actually go into the same place, so that the two dicts are now known to be just two different creation points for what is essentially the same kind of dict. So unionof() has the side-effect of making def1 and def2 complete synonyms. Now the two SomeDict()s stand for the same possibly larger set of run-time dictionaries. A bientot, Armin. _______________________________________________ pypy-dev@codespeak.net http://codespeak.net/mailman/listinfo/pypy-dev