Cython has moved to github.
cython-devel
view tests/run/dictcomp.pyx @ 1622:4f0327bdebc9
test for temp allocation bug in call
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Sat Jan 17 01:25:34 2009 -0800 (3 years ago) |
| parents | b638811d14d0 |
| children | 109840788023 |
line source
1 __doc__ = u"""
2 >>> type(smoketest()) is dict
3 True
5 >>> sorted(smoketest().items())
6 [(2, 0), (4, 4), (6, 8)]
7 >>> list(typed().items())
8 [(A, 1), (A, 1), (A, 1)]
9 >>> sorted(iterdict().items())
10 [(1, 'a'), (2, 'b'), (3, 'c')]
11 """
13 def smoketest():
14 return {x+2:x*2 for x in range(5) if x % 2 == 0}
16 cdef class A:
17 def __repr__(self): return u"A"
18 def __richcmp__(one, other, op): return one is other
19 def __hash__(self): return id(self) % 65536
21 def typed():
22 cdef A obj
23 return {obj:1 for obj in [A(), A(), A()]}
25 def iterdict():
26 cdef dict d = dict(a=1,b=2,c=3)
27 return {d[key]:key for key in d}
29 def sorted(it):
30 l = list(it)
31 l.sort()
32 return l
