|  | 
|  | 1 | +# IPython log file | 
|  | 2 | + | 
|  | 3 | + | 
|  | 4 | +get_ipython().magic(u'run decorators.py') | 
|  | 5 | +add | 
|  | 6 | +add(2,3) | 
|  | 7 | +get_ipython().magic(u'run decorators.py') | 
|  | 8 | +add(2,3) | 
|  | 9 | +new_add = substitute(add) | 
|  | 10 | +new_add(2,3) | 
|  | 11 | +@substitute | 
|  | 12 | +def fun(1,2,3) | 
|  | 13 | +@substitute | 
|  | 14 | +def fun(1,2,3): | 
|  | 15 | +    print "in fun" | 
|  | 16 | +     | 
|  | 17 | +@substitute | 
|  | 18 | +def fun(a,b): | 
|  | 19 | +    print "in fun" | 
|  | 20 | +     | 
|  | 21 | +fun() | 
|  | 22 | +@logged_func | 
|  | 23 | +def fun(a,b): | 
|  | 24 | +    print "in fun" | 
|  | 25 | +     | 
|  | 26 | +fun(2,3) | 
|  | 27 | +fun(2,3,fred=4) | 
|  | 28 | +get_ipython().magic(u'run decorators.py') | 
|  | 29 | +get_ipython().magic(u'timeit sum2x(10)') | 
|  | 30 | +get_ipython().magic(u'run decorators.py') | 
|  | 31 | +get_ipython().magic(u'timeit sum2x(10)') | 
|  | 32 | +sum2x(100000000) | 
|  | 33 | +sum2x(100000000) | 
|  | 34 | +sum2x(10000000) | 
|  | 35 | +sum2x(10000000) | 
|  | 36 | +type(sum2x) | 
|  | 37 | +sum2x.function | 
|  | 38 | +sum2x.function(10) | 
|  | 39 | +sum2x.memoized | 
|  | 40 | +@Memoize | 
|  | 41 | +def other_fun(): | 
|  | 42 | +def other_fun(x): | 
|  | 43 | +     | 
|  | 44 | +@Memoize | 
|  | 45 | +def fun2(x): | 
|  | 46 | +    return x**100 | 
|  | 47 | + | 
|  | 48 | +fun2(4) | 
|  | 49 | +fun2(4) | 
|  | 50 | +fun2.memoized | 
|  | 51 | +@Memoize | 
|  | 52 | +def fun2asdf(x): | 
|  | 53 | +    return x**100 | 
|  | 54 | + | 
|  | 55 | +get_ipython().magic(u'run decorators.py') | 
|  | 56 | +sum2x(1e6) | 
|  | 57 | +sum2x(1000000) | 
|  | 58 | +get_ipython().magic(u'run decorators.py') | 
|  | 59 | +sum2x(1000000) | 
|  | 60 | +sum2x(1000000) | 
|  | 61 | +sum2x(10000000) | 
|  | 62 | +sum2x(10000000) | 
|  | 63 | +get_ipython().magic(u'paste') | 
|  | 64 | +@Memoize | 
|  | 65 | +@timed_func | 
|  | 66 | +def sum2x(n): | 
|  | 67 | +    return sum(2 * i for i in xrange(n)) | 
|  | 68 | +sum2x(1000000) | 
|  | 69 | +sum2x(1000000) | 
|  | 70 | +get_ipython().magic(u'run context_managers.py') | 
|  | 71 | +with Context(False): | 
|  | 72 | +    print something | 
|  | 73 | +     | 
|  | 74 | +with Context(False): | 
|  | 75 | +    print "something" | 
|  | 76 | +     | 
|  | 77 | +get_ipython().magic(u'paste') | 
|  | 78 | +with Context(True) as foo: | 
|  | 79 | +    print 'This is in the context' | 
|  | 80 | +    raise RuntimeError('this is the error message') | 
|  | 81 | +with Context(False): | 
|  | 82 | +    raise RuntimeError('this is the error message') | 
|  | 83 | + | 
|  | 84 | +with context(False): | 
|  | 85 | +    raise RuntimeError('this is the error message') | 
|  | 86 | + | 
|  | 87 | +with context(True): | 
|  | 88 | +    raise RuntimeError('this is the error message') | 
|  | 89 | + | 
|  | 90 | +get_ipython().magic(u'run timer_context.py') | 
|  | 91 | +with Timer as t: | 
|  | 92 | +    [x^2 for x in range(100000000)] | 
|  | 93 | +     | 
|  | 94 | +get_ipython().magic(u'run timer_context.py') | 
|  | 95 | +with Timer as t: | 
|  | 96 | +    [x^2 for x in range(100000000)] | 
|  | 97 | +     | 
|  | 98 | +with Timer as t: | 
|  | 99 | +    [x^2 for x in range(100000000)] | 
|  | 100 | +     | 
|  | 101 | +get_ipython().magic(u'run timer_context.py') | 
|  | 102 | +with Timer as t: | 
|  | 103 | +    [x^2 for x in range(100000000)] | 
|  | 104 | +     | 
|  | 105 | +with Timer() as t: | 
|  | 106 | +    [x^2 for x in range(100000000)] | 
|  | 107 | +     | 
|  | 108 | +with Timer() as t: | 
|  | 109 | +    [x^2 for x in range(1000000)] | 
|  | 110 | +     | 
|  | 111 | +get_ipython().magic(u'run timer_context.py') | 
|  | 112 | +with Timer() as t: | 
|  | 113 | +    [x^2 for x in range(1000000)] | 
|  | 114 | +     | 
|  | 115 | +get_ipython().magic(u'run timer_context.py') | 
|  | 116 | +with Timer() as t: | 
|  | 117 | +    [x^2 for x in range(1000000)] | 
|  | 118 | +     | 
|  | 119 | +get_ipython().magic(u'run timer_context.py') | 
|  | 120 | +with Timer() as t: | 
|  | 121 | +    [x^2 for x in range(1000000)] | 
|  | 122 | +     | 
|  | 123 | +with Timer() as t: | 
|  | 124 | +    [x^2 for x in range(10000000)] | 
|  | 125 | +     | 
|  | 126 | +t | 
|  | 127 | +t.elapsed | 
|  | 128 | +with Timer() as t: | 
|  | 129 | +    [x^2 for x in range(10000000)] | 
|  | 130 | +    raise RuntimeError("this is an error") | 
|  | 131 | + | 
|  | 132 | +with Timer() as t: | 
|  | 133 | +    [x^2 for x in range(10000000)] | 
|  | 134 | +    raise RuntimeError("this is an error") | 
|  | 135 | + | 
|  | 136 | +with Timer() as t: | 
|  | 137 | +    [x^2 for x in range(10000000)] | 
|  | 138 | +    raise RuntimeError("this is an error") | 
|  | 139 | + | 
|  | 140 | +get_ipython().magic(u'run timer_context.py') | 
|  | 141 | +with Timer() as t: | 
|  | 142 | +    [x^2 for x in range(10000000)] | 
|  | 143 | +    raise RuntimeError("this is an error") | 
|  | 144 | + | 
|  | 145 | +get_ipython().magic(u'run timer_context.py') | 
|  | 146 | +with Timer() as t: | 
|  | 147 | +    [x^2 for x in range(10000000)] | 
|  | 148 | +    raise RuntimeError("this is an error") | 
|  | 149 | + | 
|  | 150 | +get_ipython().magic(u'run timer_context.py') | 
|  | 151 | +with Timer() as t: | 
|  | 152 | +    [x^2 for x in range(10000000)] | 
|  | 153 | +    raise RuntimeError("this is an error") | 
|  | 154 | + | 
|  | 155 | +get_ipython().magic(u'pinfo isinstance') | 
|  | 156 | +get_ipython().magic(u'run timer_context.py') | 
|  | 157 | +with Timer() as t: | 
|  | 158 | +    [x^2 for x in range(10000000)] | 
|  | 159 | +    raise RuntimeError("this is an error") | 
|  | 160 | + | 
|  | 161 | +get_ipython().magic(u'run timer_context.py') | 
|  | 162 | +with Timer() as t: | 
|  | 163 | +    [x^2 for x in range(10000000)] | 
|  | 164 | +    raise RuntimeError("this is an error") | 
|  | 165 | + | 
|  | 166 | +with Timer() as t: | 
|  | 167 | +    [x^2 for x in range(10000000)] | 
|  | 168 | +    raise RuntimeError("this is an error") | 
|  | 169 | +print "after Exception" | 
|  | 170 | + | 
|  | 171 | +with Timer() as t: | 
|  | 172 | +    [x^2 for x in range(10000000)] | 
|  | 173 | +    raise RuntimeError("this is an error") | 
|  | 174 | +    print "after Exception" | 
|  | 175 | + | 
|  | 176 | +with Timer() as t: | 
|  | 177 | +    [x^2 for x in range(10000000)] | 
|  | 178 | +    raise ValueError("this is an error") | 
|  | 179 | +    print "after Exception" | 
|  | 180 | + | 
0 commit comments