コード例 #1
0
 def _get_list_of_descrs(self):
     descrs = []
     for item in self._items:
         item_descrs = item.keys()
         sort_descrs(item_descrs)
         descrs.append(item_descrs)
     return descrs
コード例 #2
0
 def _get_field_descr_list(self):
     _cached_sorted_fields = self._cached_sorted_fields
     if self._fields is None:
         nfields = 0
     else:
         nfields = len(self._fields)
     if (_cached_sorted_fields is not None
             and nfields == len(_cached_sorted_fields)):
         lst = self._cached_sorted_fields
     else:
         if self._fields is None:
             lst = []
         else:
             lst = self._fields.keys()
         sort_descrs(lst)
         cache = get_fielddescrlist_cache(self.cpu)
         result = cache.get(lst, None)
         if result is None:
             cache[lst] = lst
         else:
             lst = result
         # store on self, to not have to repeatedly get it from the global
         # cache, which involves sorting
         self._cached_sorted_fields = lst
     return lst
コード例 #3
0
ファイル: virtualize.py プロジェクト: charred/pypy
 def _get_list_of_descrs(self):
     descrs = []
     for item in self._items:
         item_descrs = item.keys()
         sort_descrs(item_descrs)
         descrs.append(item_descrs)
     return descrs
コード例 #4
0
ファイル: virtualize.py プロジェクト: charred/pypy
 def _get_field_descr_list(self):
     _cached_sorted_fields = self._cached_sorted_fields
     if self._fields is None:
         nfields = 0
     else:
         nfields = len(self._fields)
     if (_cached_sorted_fields is not None and
         nfields == len(_cached_sorted_fields)):
         lst = self._cached_sorted_fields
     else:
         if self._fields is None:
             lst = []
         else:
             lst = self._fields.keys()
         sort_descrs(lst)
         cache = get_fielddescrlist_cache(self.cpu)
         result = cache.get(lst, None)
         if result is None:
             cache[lst] = lst
         else:
             lst = result
         # store on self, to not have to repeatedly get it from the global
         # cache, which involves sorting
         self._cached_sorted_fields = lst
     return lst
コード例 #5
0
ファイル: test_util.py プロジェクト: cimarieta/usp
def test_sort_descrs():
    class PseudoDescr(AbstractDescr):
        def __init__(self, n):
            self.n = n
        def sort_key(self):
            return self.n
    for i in range(17):
        lst = [PseudoDescr(j) for j in range(i)]
        lst2 = lst[:]
        random.shuffle(lst2)
        sort_descrs(lst2)
        assert lst2 == lst
コード例 #6
0
ファイル: test_util.py プロジェクト: weijiwei/pypy
def test_sort_descrs():
    class PseudoDescr(AbstractDescr):
        def __init__(self, n):
            self.n = n
        def sort_key(self):
            return self.n
    for i in range(17):
        lst = [PseudoDescr(j) for j in range(i)]
        lst2 = lst[:]
        random.shuffle(lst2)
        sort_descrs(lst2)
        assert lst2 == lst