forked from alexmojaki/birdseye
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_usage.py
More file actions
120 lines (89 loc) · 1.9 KB
/
Copy pathexample_usage.py
File metadata and controls
120 lines (89 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from itertools import islice
from random import shuffle
from birdseye import eye
@eye
def factorial(n):
if n <= 1:
return 1
return n * factorial(n - 1)
def foo(*args):
pass
class A(object):
def __init__(self):
self.x = 1
self.y = 2
class B(object):
__slots__ = ('slot1', 'slot2')
def __init__(self):
self.slot1 = 3
self.slot2 = 4
@eye
def complex_args(pos1, pos2, key1=3, key2=4, *args, **kwargs):
pass
@eye
def gen():
for i in range(6):
yield i
@eye
def use_gen_1(g):
for x in islice(g, 3):
print('foo', x)
@eye
def use_gen_2(g):
for y in g:
print('bar', y)
@eye
def quicksort(lst):
if len(lst) <= 1:
return lst
else:
pivot = lst[0]
left = []
right = []
for x in lst[1:]:
if x < pivot:
left.append(x)
else:
right.append(x)
return quicksort(left) + [pivot] + quicksort(right)
@eye
def main():
factorial(5)
vals = []
for i in range(100):
vals.append([])
for j in range(2 * i):
vals[-1].append(i + j)
vals
for i in range(6):
try:
foo(1 / (i % 2) + 10)
except ZeroDivisionError:
pass
lst = [[x + y for x in range(100)] for y in range(100)]
x = {
'a': A(),
'b': B(),
'tup': (7, 8, 9),
'lst': lst,
'string': "Hello World!" * 50,
'none': None,
'true': True,
'false': False
}
x['x'] = x
len(x)
complex_args(list(range(1000)),
"hello",
key2=8,
kwarg1={},
kwarg2=[])
g = gen()
use_gen_1(g)
use_gen_2(g)
lst = list(range(100))
original = lst[:]
shuffle(lst)
assert lst != original
assert quicksort(lst) == original
main()