示例#1
0
 def ref(self, key):
     try:
         hash(key)
     except TypeError:
         return self._iddict, Hashable(key)   # key is not hashable
     try:
         weakref.ref(key)
     except TypeError:
         return self._regdict, key            # key cannot be weakly ref'ed
     else:
         return self._weakdict, key           # normal case
示例#2
0
    def see_instance(self, x):
        assert isinstance(x, self.classdesc.pyobj)
        key = Hashable(x)
        if key in self.instances_seen:
            return
        self.instances_seen.add(key)
        self.bookkeeper.event('mutable', x)
        source = InstanceSource(self.bookkeeper, x)

        def delayed():
            for attr in source.all_instance_attributes():
                self.add_source_for_attribute(attr, source)
                # ^^^ can trigger reflowing

        self._see_instance_flattenrec(delayed)
示例#3
0
 def __init__(self, value, concretetype=None):
     Hashable.__init__(self, value)
     if concretetype is not None:
         self.concretetype = concretetype
示例#4
0
文件: model.py 项目: Darriall/pypy
 def __init__(self, value, concretetype=None):
     Hashable.__init__(self, value)
     if concretetype is not None:
         self.concretetype = concretetype
示例#5
0
 def __hash__(self):
     return hash((self.__class__, self.type, Hashable(self.instance)))