sum?
sum??
type??
import numpy as np
np.*load*?
a = np.random.randn(100,100)
timeit np.dot(a,a)
10000 loops, best of 3: 86.1 µs per loop
reset?
magic
quickref
who_ls
['a', 'np']
hist
sum? sum?? type?? import numpy as np np.*load* np.*load*? %paste a = np,random.randn(100,100) a = np.random.randn(100,100) timeit np.dot(a,a) reset? magic quickref who whos who_ls hist
gui
3*4
12
_
12
foo='bar'
_i21
u"foo='bar'"
_22
u"foo='bar'"
exec _i21
logstart
Activating auto-logging. Current session state plus future input saved. Filename : ipython_log.py Mode : rotate Output logging : False Raw input log : False Timestamping : False State : active
!ls
README.md chp3_Ipython.ipynb chp2_Introductory_examples.ipynb ipython_log.py
!whoami
sergulaydore
ip_info = !ifconfig | grep "inet "
ip_info[0].strip()
'inet 127.0.0.1 netmask 0xff000000'
foo='c*'
!ls $foo
chp2_Introductory_examples.ipynb chp3_Ipython.ipynb
%alias ll ls -l
ll /usr
total 16 drwxr-xr-x 5 root wheel 170 Sep 9 17:41 X11 lrwxr-xr-x 1 root wheel 3 Feb 22 20:16 X11R6 -> X11 drwxr-xr-x 1048 root wheel 35632 Feb 22 21:10 bin drwxr-xr-x 251 root wheel 8534 Feb 22 21:12 lib drwxr-xr-x 170 root wheel 5780 Feb 22 21:16 libexec drwxr-xr-x 6 root wheel 204 Feb 22 20:22 local drwxr-xr-x 243 root wheel 8262 Feb 22 20:15 sbin drwxr-xr-x 43 root wheel 1462 Feb 22 20:15 share drwxr-xr-x 4 root wheel 136 Feb 22 20:11 standalone lrwxr-xr-x 1 root wheel 44 Sep 18 12:18 texbin -> ../Library/TeX/Distributions/Programs/texbin
%bookmark db ../Dropbox
cd db
(bookmark:db) -> ../Dropbox /Users/sergulaydore/Dropbox
%bookmark -l
Current bookmarks: db -> ../Dropbox
import time
strings = ['foo','foobar','baz','qux',
'python', 'Guido Van Rossum']*100000 # a very large list of strings
%time method1 = [x for x in strings if x.startswith('foo')]
CPU times: user 213 ms, sys: 11.2 ms, total: 224 ms Wall time: 219 ms
%time method2 = [x for x in strings if x[:3]=='foo']
CPU times: user 114 ms, sys: 17.9 ms, total: 132 ms Wall time: 121 ms
%timeit method1 = [x for x in strings if x.startswith('foo')]
1 loops, best of 3: 164 ms per loop
%timeit method2 = [x for x in strings if x[:3]=='foo']
10 loops, best of 3: 57.3 ms per loop
python -m cProfile cprof_example.py
python -m cProfile -s cumulative cprof_example.py
%prun -l 7 -s cumulative run_experiment()
class Message:
def __init__(self, msg):
self.msg = msg
x = Message('I have a secret')
x
<__main__.Message instance at 0x10445f248>
class Message:
def __init__(self,msg):
self.msg = msg
def __repr__(self):
return 'Message: %s' %self.msg
x=Message('I have a secret')
x
Message: I have a secret