Ejemplo n.º 1
0
def ll_dict_kvi(d, LIST, func):
    length = d.ll_length()
    result = ll_newlist(LIST, length)
    it = d.ll_get_items_iterator()
    i = 0
    while it.ll_go_next():
        if func is dum_keys:
            result.ll_setitem_fast(i, it.ll_current_key())
        elif func is dum_values:
            result.ll_setitem_fast(i, it.ll_current_value())
        if func is dum_items:
            r = ootype.new(LIST._ITEMTYPE)
            r.item0 = it.ll_current_key()  # TODO: do we need casting?
            r.item1 = it.ll_current_value()
            result.ll_setitem_fast(i, r)
        i += 1
    assert i == length
    return result
Ejemplo n.º 2
0
def ll_dict_kvi(d, LIST, func):
    length = d.ll_length()
    result = ll_newlist(LIST, length)
    it = d.ll_get_items_iterator()
    i = 0
    while it.ll_go_next():
        if func is dum_keys:
            result.ll_setitem_fast(i, it.ll_current_key())
        elif func is dum_values:
            result.ll_setitem_fast(i, it.ll_current_value())
        if func is dum_items:
            r = ootype.new(LIST._ITEMTYPE)
            r.item0 = it.ll_current_key()   # TODO: do we need casting?
            r.item1 = it.ll_current_value()
            result.ll_setitem_fast(i, r)
        i += 1
    assert i == length
    return result
Ejemplo n.º 3
0
 def ll_newlist(self, length):
     from pypy.rpython.ootypesystem import rlist
     return rlist.ll_newlist(self, length)