forked from UWPCE-PythonCert/IntroToPython-2014
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipythonlog.txt
More file actions
180 lines (146 loc) · 3.84 KB
/
ipythonlog.txt
File metadata and controls
180 lines (146 loc) · 3.84 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# IPython log file
get_ipython().magic(u'run decorators.py')
add
add(2,3)
get_ipython().magic(u'run decorators.py')
add(2,3)
new_add = substitute(add)
new_add(2,3)
@substitute
def fun(1,2,3)
@substitute
def fun(1,2,3):
print "in fun"
@substitute
def fun(a,b):
print "in fun"
fun()
@logged_func
def fun(a,b):
print "in fun"
fun(2,3)
fun(2,3,fred=4)
get_ipython().magic(u'run decorators.py')
get_ipython().magic(u'timeit sum2x(10)')
get_ipython().magic(u'run decorators.py')
get_ipython().magic(u'timeit sum2x(10)')
sum2x(100000000)
sum2x(100000000)
sum2x(10000000)
sum2x(10000000)
type(sum2x)
sum2x.function
sum2x.function(10)
sum2x.memoized
@Memoize
def other_fun():
def other_fun(x):
@Memoize
def fun2(x):
return x**100
fun2(4)
fun2(4)
fun2.memoized
@Memoize
def fun2asdf(x):
return x**100
get_ipython().magic(u'run decorators.py')
sum2x(1e6)
sum2x(1000000)
get_ipython().magic(u'run decorators.py')
sum2x(1000000)
sum2x(1000000)
sum2x(10000000)
sum2x(10000000)
get_ipython().magic(u'paste')
@Memoize
@timed_func
def sum2x(n):
return sum(2 * i for i in xrange(n))
sum2x(1000000)
sum2x(1000000)
get_ipython().magic(u'run context_managers.py')
with Context(False):
print something
with Context(False):
print "something"
get_ipython().magic(u'paste')
with Context(True) as foo:
print 'This is in the context'
raise RuntimeError('this is the error message')
with Context(False):
raise RuntimeError('this is the error message')
with context(False):
raise RuntimeError('this is the error message')
with context(True):
raise RuntimeError('this is the error message')
get_ipython().magic(u'run timer_context.py')
with Timer as t:
[x^2 for x in range(100000000)]
get_ipython().magic(u'run timer_context.py')
with Timer as t:
[x^2 for x in range(100000000)]
with Timer as t:
[x^2 for x in range(100000000)]
get_ipython().magic(u'run timer_context.py')
with Timer as t:
[x^2 for x in range(100000000)]
with Timer() as t:
[x^2 for x in range(100000000)]
with Timer() as t:
[x^2 for x in range(1000000)]
get_ipython().magic(u'run timer_context.py')
with Timer() as t:
[x^2 for x in range(1000000)]
get_ipython().magic(u'run timer_context.py')
with Timer() as t:
[x^2 for x in range(1000000)]
get_ipython().magic(u'run timer_context.py')
with Timer() as t:
[x^2 for x in range(1000000)]
with Timer() as t:
[x^2 for x in range(10000000)]
t
t.elapsed
with Timer() as t:
[x^2 for x in range(10000000)]
raise RuntimeError("this is an error")
with Timer() as t:
[x^2 for x in range(10000000)]
raise RuntimeError("this is an error")
with Timer() as t:
[x^2 for x in range(10000000)]
raise RuntimeError("this is an error")
get_ipython().magic(u'run timer_context.py')
with Timer() as t:
[x^2 for x in range(10000000)]
raise RuntimeError("this is an error")
get_ipython().magic(u'run timer_context.py')
with Timer() as t:
[x^2 for x in range(10000000)]
raise RuntimeError("this is an error")
get_ipython().magic(u'run timer_context.py')
with Timer() as t:
[x^2 for x in range(10000000)]
raise RuntimeError("this is an error")
get_ipython().magic(u'pinfo isinstance')
get_ipython().magic(u'run timer_context.py')
with Timer() as t:
[x^2 for x in range(10000000)]
raise RuntimeError("this is an error")
get_ipython().magic(u'run timer_context.py')
with Timer() as t:
[x^2 for x in range(10000000)]
raise RuntimeError("this is an error")
with Timer() as t:
[x^2 for x in range(10000000)]
raise RuntimeError("this is an error")
print "after Exception"
with Timer() as t:
[x^2 for x in range(10000000)]
raise RuntimeError("this is an error")
print "after Exception"
with Timer() as t:
[x^2 for x in range(10000000)]
raise ValueError("this is an error")
print "after Exception"