Beispiel #1
0
 def foo(na, nb, fa, fb):
     da = dictobject.new_dict(int32, float64)
     db = dictobject.new_dict(int32, float64)
     for i in range(na):
         da[i] = i * fa
     for i in range(nb):
         db[i] = i * fb
     return da == db, da != db
Beispiel #2
0
 def foo(ak, av, bk, bv):
     # The key-value types are different in the two dictionaries
     da = dictobject.new_dict(int32, float64)
     db = dictobject.new_dict(int64, float32)
     for i in range(len(ak)):
         da[ak[i]] = av[i]
     for i in range(len(bk)):
         db[bk[i]] = bv[i]
     return da == db
Beispiel #3
0
 def foo(keys, vals, target):
     d = dictobject.new_dict(int32, float64)
     # insertion
     for k, v in zip(keys, vals):
         d[k] = v
     del d[target]
     return len(d), d.get(target)
Beispiel #4
0
 def foo(keys, vals, pops):
     d = dictobject.new_dict(int32, float64)
     # insertion
     for k, v in zip(keys, vals):
         d[k] = v
     # popitem
     return core(d, pops)
Beispiel #5
0
        def foo(keys, vals, npop):
            d = dictobject.new_dict(int32, int32)
            # insertion
            for k, v in zip(keys, vals):
                d[k] = v

            return core(d, npop)
Beispiel #6
0
 def foo(n):
     d = dictobject.new_dict(int32, float64)
     for i in range(n):
         d[i] = i + 1
     # bad cast!?
     z = d.get(2.4)
     return z
Beispiel #7
0
 def foo(n, target, default):
     d = dictobject.new_dict(int32, float64)
     # insertion loop
     for i in range(n):
         d[i] = i
     # retrieval loop
     return d.get(target, default)
Beispiel #8
0
        def foo():
            d = dictobject.new_dict(int32, float64)
            e = d
            d[1] = 12.
            e[2] = 14.
            e = dictobject.new_dict(int32, float64)
            e[1] = 100.
            e[2] = 1000.
            f = d
            d = e

            k1 = [x for x in d.items()]
            k2 = [x for x in e.items()]
            k3 = [x for x in f.items()]

            return k1, k2, k3
Beispiel #9
0
 def foo(n):
     d = dictobject.new_dict(int32, float64)
     for i in range(n):
         d[i] = i + 1
     # bad default type
     z = d.get(2 * n, 1j)
     return z
Beispiel #10
0
        def foo(keys, vals, target):
            d = dictobject.new_dict(int32, float64)
            # insertion
            for k, v in zip(keys, vals):
                d[k] = v

            # popitem
            return d.pop(target, None), len(d)
Beispiel #11
0
        def foo(keys, vals, target):
            d = dictobject.new_dict(int32, float64)
            # insertion
            for k, v in zip(keys, vals):
                d[k] = v

            # lookup
            return d[target]
Beispiel #12
0
 def foo(v1, v2):
     d = dictobject.new_dict(int64, float64)
     c1 = np.uint64(2 ** 61 - 1)
     c2 = np.uint64(0)
     assert hash(c1) == hash(c2)
     d[c1] = v1
     d[c2] = v2
     return (d[c1], d[c2])
Beispiel #13
0
 def foo(n):
     d = dictobject.new_dict(int32, float64)
     for i in range(n):
         d[i] = i + 1
     x = len(d)
     d.clear()
     y = len(d)
     return x, y
Beispiel #14
0
        def foo():
            d = dictobject.new_dict(int32, float64)

            def bar():
                d[1] = 12.
                d[2] = 14.
            bar()
            return [x for x in d.keys()]
Beispiel #15
0
 def foo(keys, vals):
     d = dictobject.new_dict(int32, float64)
     # insertion
     for k, v in zip(keys, vals):
         d[k] = v
     b4 = len(d)
     # clear
     d.clear()
     return b4, len(d)
Beispiel #16
0
 def foo(keys, vals, checklist):
     d = dictobject.new_dict(int32, float64)
     # insertion
     for k, v in zip(keys, vals):
         d[k] = v
     out = []
     for k in checklist:
         out.append(k in d)
     return out
Beispiel #17
0
 def foo(keys, vals):
     d = dictobject.new_dict(int32, float64)
     # insertion
     for k, v in zip(keys, vals):
         d[k] = v
     out = []
     for v in d.values():
         out.append(v)
     return out
Beispiel #18
0
 def foo():
     d = dictobject.new_dict(int32, float64)
     d[11] = 12.
     k1 = d.keys()
     d[22] = 9.
     k2 = d.keys()
     rk1 = [x for x in k1]
     rk2 = [x for x in k2]
     return rk1, rk2
Beispiel #19
0
 def foo():
     d = dictobject.new_dict(types.unicode_type, float64)
     tmp = []
     for i in range(10000):
         tmp.append('a')
     s = ''.join(tmp)
     d[s] = 1.
     out = list(d.items())
     return out
Beispiel #20
0
 def foo(n, targets):
     d = dictobject.new_dict(int32, float64)
     # insertion loop
     for i in range(n):
         d[i] = i
     # retrieval loop
     output = []
     for t in targets:
         output.append(d.get(t))
     return output
Beispiel #21
0
 def foo():
     d = dictobject.new_dict(int32, float64)
     d.setdefault(1, 1.2) # used because key is not in
     a = d.get(1)
     d[1] = 2.3
     b = d.get(1)
     d[2] = 3.4
     d.setdefault(2, 4.5)  # not used because key is in
     c = d.get(2)
     return a, b, c
Beispiel #22
0
 def foo():
     d = dictobject.new_dict(types.unicode_type, float64)
     d['a'] = 1.
     d['b'] = 2.
     d['c'] = 3.
     d['d'] = 4.
     out = []
     for x in d.items():
         out.append(x)
     return out, d['a']
Beispiel #23
0
 def foo(n):
     d = dictobject.new_dict(int32, float64)
     for i in range(n):
         d[i] = i + 1
     keys = []
     vals = []
     for i in range(n):
         tmp = d.popitem()
         keys.append(tmp[0])
         vals.append(tmp[1])
     return keys, vals
 def foo():
     d = dictobject.new_dict(int32, float64)
     out = []
     for kv in d.items():
         out.append(kv)
     return out
 def foo():
     d = dictobject.new_dict(int32, float64)
     # popitem
     return d.pop(0)
Beispiel #26
0
 def foo():
     d = dictobject.new_dict(int32, float64)
     # default value is wrong type
     d.setdefault(1, 12.j)
Beispiel #27
0
 def foo():
     d = dictobject.new_dict(int32, float64)
     # not contains empty dict
     return 1 not in d
 def foo():
     d = dictobject.new_dict(int32, float64)
     d[0] = 6.
     # invalid key type
     return 1j in d
 def foo():
     d = dictobject.new_dict(int32, float64)
     d[0] = 6.
     d[1] = 7.
     # pop'd default must have same type as value
     d.pop(11, 12j)
Beispiel #30
0
 def foo():
     d = dictobject.new_dict(int32, float64)
     # default value is wrong type
     d.setdefault(1, 12.j)
 def foo(na, b):
     da = dictobject.new_dict(int32, float64)
     for i in range(na):
         da[i] = i
     return da == b
Beispiel #32
0
 def foo():
     d = dictobject.new_dict(int32, float64)
     d[0] = 6.
     # invalid key type
     return 1j in d
Beispiel #33
0
 def foo():
     d = dictobject.new_dict(int32, float64)
     d[0] = 6.
     d[1] = 7.
     # pop'd key must have same type as key
     d.pop(11j)
 def foo():
     d = dictobject.new_dict(int32, float64)
     # not contains empty dict
     return 1 not in d
 def foo(n):
     d = dictobject.new_dict(int32, float32)
     for i in range(n):
         d[i] = i + 1
     return len(d)
 def foo():
     d = dictobject.new_dict(int32, float64)
     # should raise TypingError
     d[1] = 1j
 def foo(keys, vals):
     d = dictobject.new_dict(int32, float64)
     # insertion
     for k, v in zip(keys, vals):
         d[k] = v
     return list(d.copy().items())
Beispiel #38
0
 def foo():
     d = dictobject.new_dict(int32, float64)
     # key is wrong type
     d.setdefault(1j, 12.)
 def boxer(nelem):
     d = dictobject.new_dict(int32, float64)
     for k, v in make_content(nelem):
         d[k] = v
     return dictobject._as_meminfo(d)
Beispiel #40
0
 def foo():
     d = dictobject.new_dict(int32, float64)
     d[11] = 12.
     d[22] = 9.
     k2 = d.keys() & {12,}
     return k2
 def foo():
     d = dictobject.new_dict(int32, float64)
     # raise TypingError
     d[11.5]
Beispiel #42
0
def _make_dict(keyty, valty):
    return dictobject._as_meminfo(dictobject.new_dict(keyty, valty))
 def foo():
     d = dictobject.new_dict(int32, float64)
     d[0] = 6.
     d[1] = 7.
     # pop'd key must have same type as key
     d.pop(11j)
Beispiel #44
0
 def impl(cls, key_type, value_type):
     return dictobject.new_dict(key_type, value_type)
 def foo():
     d = dictobject.new_dict(int32, float64)
     # contains on empty dict
     return 1 in d
Beispiel #46
0
 def foo():
     d = dictobject.new_dict(int32, float64)
     # contains on empty dict
     return 1 in d
 def foo():
     d = dictobject.new_dict(int32, float64)
     # key is wrong type
     d.setdefault(1j, 12.)
Beispiel #48
0
 def foo():
     d = dictobject.new_dict(int32, float64)
     d[11] = 12.
     d[22] = 9.
     k2 = d.keys() & {12,}
     return k2