\n", " | Command | \n", "Comment | \n", "
---|---|---|
0 | \n", "%quickref | \n", "IPython\uc758 \ube60\ub978 \ub3c4\uc6c0\ub9d0 \ud45c\uc2dc | \n", "
1 | \n", "%magic | \n", "\ubaa8\ub4e0 \ub9e4\uc9c1 \ud568\uc218\uc5d0 \ub300\ud55c \uc0c1\uc138 \ub3c4\uc6c0\ub9d0 \ucd9c\ub825 | \n", "
2 | \n", "%debug | \n", "\ucd5c\uadfc \uc608\uc678 \ud2b8\ub808\uc774\uc2a4\ubc31\uc758 \ud558\ub2e8\uc5d0\uc11c \ub300\ud654\ud615 \ub514\ubc84\uac70\ub85c \uc9c4\uc785 | \n", "
3 | \n", "%hist | \n", "\uba85\ub839\uc5b4 \uc785\ub825(\uadf8\ub9ac\uace0 \uc120\ud0dd\uc801\uc73c\ub85c \ucd9c\ub825) \ud788\uc2a4\ud1a0\ub9ac \ucd9c\ub825 | \n", "
4 | \n", "%pdb | \n", "\uc608\uc678\uac00 \ubc1c\uc0dd\ud558\uba74 \uc790\ub3d9\uc801\uc73c\ub85c \ub514\ubc84\uac70\ub85c \uc9c4\uc785 | \n", "
5 | \n", "%paste | \n", "\ud074\ub9bd\ubcf4\ub4dc\uc5d0\uc11c \ub4e4\uc5ec\uc4f0\uae30\uac00 \ub41c \ucc44\ub85c \ud30c\uc774\uc36c \ucf54\ub4dc \uac00\uc838\uc624\uae30 | \n", "
6 | \n", "%cpaste | \n", "\uc2e4\ud589 \ud30c\uc774\uc36c \ucf54\ub4dc\ub97c \uc218\ub3d9\uc73c\ub85c \ubd99\uc5ec\ub123\uc744 \uc218 \uc788\ub294 \ud504\ub86c\ud504\ud2b8 \ud45c\uc2dc | \n", "
7 | \n", "%reset | \n", "\ub300\ud654\ud615 \ub124\uc784\uc2a4\ud398\uc774\uc2a4\uc5d0\uc11c \uc815\uc758\ub41c \ubaa8\ub4e0 \ubcc0\uc218\uc640 \uc774\ub984\uc744 \uc0ad\uc81c | \n", "
8 | \n", "%page | \n", "OBJECT \uac1d\uccb4\ub97c pager\ub97c \ud1b5\ud574 \ubcf4\uae30 \uc88b\uac8c \ucd9c\ub825 | \n", "
9 | \n", "%run script.py | \n", "IPython \ub0b4\uc5d0\uc11c \ud30c\uc774\uc36c \uc2a4\ud06c\ub9bd\ud2b8 \uc2e4\ud589 | \n", "
10 | \n", "%prun statement | \n", "cProfile\uc744 \ud1b5\ud574 statement\ub97c \uc2e4\ud589\ud558\uace0 \ud504\ub85c\ud30c\uc77c\ub9c1 \uacb0\uacfc\ub97c \ucd9c\ub825 | \n", "
11 | \n", "%time statement | \n", "\ub2e8\uc77c statement \uc2e4\ud589 \uc2dc\uac04\uc744 \ucd9c\ub825 | \n", "
12 | \n", "%timeit statement | \n", "statement\ub97c \uc5ec\ub7ec \ucc28\ub840 \uc2e4\ud589\ud55c \ud6c4 \ud3c9\uade0 \uc2e4\ud589 \uc2dc\uac04\uc744 \ucd9c\ub825. | \n", "
13 | \n", "\n", " | \ub9e4\uc6b0 \uc9e7\uc740 \uc2dc\uac04 \uc548\uc5d0 \ub05d\ub098\ub294 \ucf54\ub4dc\uc758 \uc2dc\uac04\uc744 \uce21\uc815\ud560 \ub54c \uc720\uc6a9 | \n", "
14 | \n", "%who, %who_ls, %whos | \n", "\ub300\ud654\ud615 \ub124\uc784\uc2a4\ud398\uc774\uc2a4 \ub0b4\uc5d0\uc11c \uc815\uc758\ub41c \ubcc0\uc218\ub97c \ub2e4\uc591\ud55c \ubc29\ubc95\uc73c\ub85c \ud45c\uc2dc | \n", "
15 | \n", "%xdel variable | \n", "variable\uc744 \uc0ad\uc81c\ud558\uace0 IPython \ub0b4\ubd80\uc801\uc73c\ub85c \ud574\ub2f9 \uac1d\uccb4\uc5d0 \ub300\ud55c \ubaa8\ub4e0 \ucc38\uc870\ub97c \uc81c\uac70 | \n", "
\n", " | Command | \n", "Comment | \n", "
---|---|---|
0 | \n", "h(elp) | \n", "\uba85\ub839\uc5b4 \ubaa9\ub85d\uc744 \ubcf4\uc5ec\uc900\ub2e4. | \n", "
1 | \n", "help command | \n", "command\uc5d0 \ub300\ud55c \ubb38\uc11c\ub97c \ubcf4\uc5ec\uc900\ub2e4. | \n", "
2 | \n", "c(continue) | \n", "\ud504\ub85c\uadf8\ub7a8\uc758 \uc2e4\ud589\uc744 \uc7ac\uac1c\ud55c\ub2e4. | \n", "
3 | \n", "q(uit) | \n", "\ub354 \uc774\uc0c1 \ucf54\ub4dc\ub97c \uc2e4\ud589\ud558\uc9c0 \uc54a\uace0 \ub514\ubc84\uac70\ub97c \uc885\ub8cc\ud55c\ub2e4. | \n", "
4 | \n", "b(reak) number | \n", "\ud604\uc7ac \ud30c\uc77c\uc758 number\ubc88\uc9f8 \uc904\uc5d0 \ube0c\ub808\uc774\ud06c\ud3ec\uc778\ud2b8\ub97c \uc124\uc815\ud55c\ub2e4. | \n", "
5 | \n", "b path/to/file.py:number | \n", "\uc9c0\uc815\ud55c \ud30c\uc77c\uc758 number\ubc88\uc9f8 \uc904\uc5d0 \ube0c\ub808\uc774\ud06c\ud3ec\uc778\ud2b8\ub97c \uc124\uc815\ud55c\ub2e4 | \n", "
6 | \n", "s(tep) | \n", "\ud568\uc218 \ud638\ucd9c \uc548\uc73c\ub85c \uc9c4\uc785\ud55c\ub2e4. | \n", "
7 | \n", "n(ext) | \n", "\ud604\uc7ac \uc904\uc744 \uc2e4\ud589\ud558\uace0 \uac19\uc740 \ub808\ubca8\uc758 \ub2e4\uc74c \uc904\ub85c \uc9c4\ud589\ud55c\ub2e4. | \n", "
8 | \n", "u(p) / d(own) | \n", "\ud568\uc218 \ucf5c \uc2a4\ud0dd(\ud638\ucd9c \uc815\ubcf4)\uc758 \uc704/\uc544\ub798\ub85c \uc774\ub3d9\ud55c\ub2e4. | \n", "
9 | \n", "a(rgs) | \n", "\ud604\uc7ac \ud568\uc218\uc758 \uc778\uc790\ub97c \ubcf4\uc5ec\uc900\ub2e4. | \n", "
10 | \n", "debug statement | \n", "statement \ubb38\uc7a5\uc744 \uc0c8\ub85c\uc6b4 (\uc7ac\uadc0\uc801) \ub514\ubc84\uac70\uc5d0\uc11c \uc2e4\ud589\ud55c\ub2e4. | \n", "
11 | \n", "l(ist) statement | \n", "\ud604\uc7ac \uc704\uce58\uc640 \uc2a4\ud0dd\uc758 \ud604\uc7ac \ub808\ubca8\uc5d0 \ub300\ud55c \ubb38\ub9e5\uc744 \ubcf4\uc5ec\uc900\ub2e4. | \n", "
12 | \n", "w(here) | \n", "\ud604\uc7ac \uc704\uce58\uc5d0 \ub300\ud55c \ubb38\ub9e5\uacfc \ud568\uaed8 \uc804\uccb4 \uc2a4\ud0dd \uc815\ubcf4\ub97c \ucd9c\ub825\ud55c\ub2e4. | \n", "
Type: Magic function\n", "String form:>\n", "Namespace: IPython internal\n", "File: /Library/Python/2.7/site-packages/IPython/core/magics/execution.py\n", "Definition: %timeit(self, line='', cell=None)\n", "Source:\n", " @skip_doctest\n", " @line_cell_magic\n", " def timeit(self, line='', cell=None):\n", " \"\"\"Time execution of a Python statement or expression\n", "\n", " Usage, in line mode:\n", " %timeit [-n -r [-t|-c] -q -p -o] statement\n", " or in cell mode:\n", " %%timeit [-n
-r [-t|-c] -q -p -o] setup_code\n", " code\n", " code...\n", "\n", " Time execution of a Python statement or expression using the timeit\n", " module. This function can be used both as a line and cell magic:\n", "\n", " - In line mode you can time a single-line statement (though multiple\n", " ones can be chained with using semicolons).\n", "\n", " - In cell mode, the statement in the first line is used as setup code\n", " (executed but not timed) and the body of the cell is timed. The cell\n", " body has access to any variables created in the setup code.\n", "\n", " Options:\n", " -n
: execute the given statement times in a loop. If this value\n", " is not given, a fitting value is chosen.\n", "\n", " -r : repeat the loop iteration times and take the best result.\n", " Default: 3\n", "\n", " -t: use time.time to measure the time, which is the default on Unix.\n", " This function measures wall time.\n", "\n", " -c: use time.clock to measure the time, which is the default on\n", " Windows and measures wall time. On Unix, resource.getrusage is used\n", " instead and returns the CPU user time.\n", "\n", " -p : use a precision of
digits to display the timing result.\n", " Default: 3\n", "\n", " -q: Quiet, do not print result.\n", "\n", " -o: return a TimeitResult that can be stored in a variable to inspect\n", " the result in more details.\n", "\n", "\n", " Examples\n", " --------\n", " ::\n", "\n", " In [1]: %timeit pass\n", " 10000000 loops, best of 3: 53.3 ns per loop\n", "\n", " In [2]: u = None\n", "\n", " In [3]: %timeit u is None\n", " 10000000 loops, best of 3: 184 ns per loop\n", "\n", " In [4]: %timeit -r 4 u == None\n", " 1000000 loops, best of 4: 242 ns per loop\n", "\n", " In [5]: import time\n", "\n", " In [6]: %timeit -n1 time.sleep(2)\n", " 1 loops, best of 3: 2 s per loop\n", "\n", "\n", " The times reported by %timeit will be slightly higher than those\n", " reported by the timeit.py script when variables are accessed. This is\n", " due to the fact that %timeit executes the statement in the namespace\n", " of the shell, compared with timeit.py, which uses a single setup\n", " statement to import function or create variables. Generally, the bias\n", " does not matter as long as results from timeit.py are not mixed with\n", " those from %timeit.\"\"\"\n", "\n", " import timeit\n", "\n", " opts, stmt = self.parse_options(line,'n:r:tcp:qo',\n", " posix=False, strict=False)\n", " if stmt == \"\" and cell is None:\n", " return\n", " \n", " timefunc = timeit.default_timer\n", " number = int(getattr(opts, \"n\", 0))\n", " repeat = int(getattr(opts, \"r\", timeit.default_repeat))\n", " precision = int(getattr(opts, \"p\", 3))\n", " quiet = 'q' in opts\n", " return_result = 'o' in opts\n", " if hasattr(opts, \"t\"):\n", " timefunc = time.time\n", " if hasattr(opts, \"c\"):\n", " timefunc = clock\n", "\n", " timer = timeit.Timer(timer=timefunc)\n", " # this code has tight coupling to the inner workings of timeit.Timer,\n", " # but is there a better way to achieve that the code stmt has access\n", " # to the shell namespace?\n", " transform = self.shell.input_splitter.transform_cell\n", "\n", " if cell is None:\n", " # called as line magic\n", " ast_setup = ast.parse(\"pass\")\n", " ast_stmt = ast.parse(transform(stmt))\n", " else:\n", " ast_setup = ast.parse(transform(stmt))\n", " ast_stmt = ast.parse(transform(cell))\n", "\n", " ast_setup = self.shell.transform_ast(ast_setup)\n", " ast_stmt = self.shell.transform_ast(ast_stmt)\n", "\n", " # This codestring is taken from timeit.template - we fill it in as an\n", " # AST, so that we can apply our AST transformations to the user code\n", " # without affecting the timing code.\n", " timeit_ast_template = ast.parse('def inner(_it, _timer):\\n'\n", " ' setup\\n'\n", " ' _t0 = _timer()\\n'\n", " ' for _i in _it:\\n'\n", " ' stmt\\n'\n", " ' _t1 = _timer()\\n'\n", " ' return _t1 - _t0\\n')\n", "\n", " timeit_ast = TimeitTemplateFiller(ast_setup, ast_stmt).visit(timeit_ast_template)\n", " timeit_ast = ast.fix_missing_locations(timeit_ast)\n", "\n", " # Track compilation time so it can be reported if too long\n", " # Minimum time above which compilation time will be reported\n", " tc_min = 0.1\n", "\n", " t0 = clock()\n", " code = compile(timeit_ast, \"
\", \"exec\")\n", " tc = clock()-t0\n", "\n", " ns = {}\n", " exec(code, self.shell.user_ns, ns)\n", " timer.inner = ns[\"inner\"]\n", "\n", " if number == 0:\n", " # determine number so that 0.2 <= total time < 2.0\n", " number = 1\n", " for _ in range(1, 10):\n", " if timer.timeit(number) >= 0.2:\n", " break\n", " number *= 10\n", " all_runs = timer.repeat(repeat, number)\n", " best = min(all_runs) / number\n", " if not quiet :\n", " print(u\"%d loops, best of %d: %s per loop\" % (number, repeat,\n", " _format_time(best, precision)))\n", " if tc > tc_min:\n", " print(\"Compiler time: %.2f s\" % tc)\n", " if return_result:\n", " return TimeitResult(number, repeat, best, all_runs, tc, precision)" ] }, { "cell_type": "code", "collapsed": false, "input": [ "x = 'foobar'" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 78 }, { "cell_type": "code", "collapsed": false, "input": [ "y = 'foo'" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 79 }, { "cell_type": "code", "collapsed": false, "input": [ "%timeit x.startswith(y)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "1000000 loops, best of 3: 217 ns per loop\n" ] } ], "prompt_number": 80 }, { "cell_type": "code", "collapsed": false, "input": [ "%timeit x[:3] == y" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "10000000 loops, best of 3: 119 ns per loop\n" ] } ], "prompt_number": 81 }, { "cell_type": "markdown", "metadata": {}, "source": [ "- %timeit\uc740 \uba87 \ubc88 loops\ub97c \ub3cc\uc558\ub294\uc9c0 \uc11c\ub85c \ube44\uad50\ud574 \ubcf4\uba74\uc11c \ubd10\uc57c \ud55c\ub2e4. loops \ub2e8\uc704\uac00 \ub2e4\ub97c \uc218 \uc788\ub2e4." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 3.4.3 \uae30\ubcf8\uc801\uc778 \ud504\ub85c\ud30c\uc77c\ub9c1: %prun\uacfc %run -p\n", "\n", "- \ucf54\ub4dc \ud504\ub85c\ud30c\uc77c\ub9c1\uc740 \ucf54\ub4dc \uc2e4\ud589 \uc2dc\uac04 \uce21\uc815\uacfc \ubc00\uc811\ud55c \uad00\uacc4\n", "- \ud504\ub85c\ud30c\uc77c\ub9c1\uc740 \uadf8 \uc2dc\uac04\uc774 \uc5b4\ub514\uc11c \uc18c\uc694\ub418\uc5c8\ub294\uc9c0 \uce20\uac86\u3147\n", "- \uc8fc\ub85c \uc0ac\uc6a9\ub418\ub294 \ud30c\uc774\uc36c \ud504\ub85c\ud30c\uc77c\ub9c1 \ub3c4\uad6c\ub294 cProfile \ubaa8\ub4c8\uc778\ub370 IPython\uc5d0 \uad6d\ud55c\ub41c \ub3c4\uad6c\ub294 \uc544\ub2d8\n", "- cProfile\uc740 \ud504\ub85c\uadf8\ub7a8\uc774\ub098 \uc784\uc758\uc758 \ucf54\ub4dc \ube14\ub85d\uc744 \uc2e4\ud589\ud558\uba74\uc11c \uac01 \ud568\uc218\uc5d0\uc11c \uc18c\ubaa8\ub41c \uc2dc\uac04\uc744 \uacc4\uc18d \uae30\ub85d\n", "- \uba85\ub839\ud589\uc5d0\uc11c cProfile\uc744 \uc0ac\uc6a9\ud558\ub294 \uc77c\ubc18\uc801\uc778 \ubc29\ubc95\uc740 \ud504\ub85c\uadf8\ub7a8 \uc804\uccb4\ub97c \uc2e4\ud589\ud558\uace0 \uac01 \ud568\uc218\ubcc4\ub85c \uc218\uc9d1\ub41c \uc2dc\uac04 \uc815\ubcf4\ub97c \ucd9c\ub825\ud558\ub294 \ubc29\uc2dd" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%%writefile ch03/cprof_example.py\n", "\n", "import numpy as np\n", "from numpy.linalg import eigvals\n", "\n", "def run_experiment(niter=100):\n", " K = 100\n", " results = []\n", " for _ in xrange(niter):\n", " mat = np.random.randn(K, K)\n", " max_eigenvalue = np.abs(eigvals(mat)).max()\n", " results.append(max_eigenvalue)\n", " return results\n", "some_results = run_experiment()\n", "print 'Largest one we saw: %s' % np.max(some_results)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Overwriting ch03/cprof_example.py\n" ] } ], "prompt_number": 82 }, { "cell_type": "code", "collapsed": false, "input": [ "def run_experiment(niter=100):\n", " K = 100\n", " results = []\n", " for _ in xrange(niter):\n", " mat = np.random.randn(K, K)\n", " max_eigenvalue = np.abs(eigvals(mat)).max()\n", " results.append(max_eigenvalue)\n", " return results" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 83 }, { "cell_type": "code", "collapsed": false, "input": [ "!python -m cProfile -s cumulative ch03/cprof_example.py" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Largest one we saw: 11.7134449573\r\n", " 14452 function calls (14364 primitive calls) in 0.866 seconds\r\n", "\r\n", " Ordered by: cumulative time\r\n", "\r\n", " ncalls tottime percall cumtime percall filename:lineno(function)\r\n", " 1 0.001 0.001 0.868 0.868 cprof_example.py:2( )\r\n", " 1 0.002 0.002 0.715 0.715 cprof_example.py:5(run_experiment)\r\n", " 100 0.661 0.007 0.673 0.007 linalg.py:819(eigvals)\r\n", " 1 0.015 0.015 0.152 0.152 __init__.py:106( )\r\n", " 3 0.026 0.009 0.128 0.043 __init__.py:1( )\r\n", " 1 0.001 0.001 0.086 0.086 add_newdocs.py:10( )\r\n", " 1 0.001 0.001 0.050 0.050 type_check.py:3( )\r\n", " 100 0.039 0.000 0.039 0.000 {method 'randn' of 'mtrand.RandomState' objects}\r\n", " 1 0.005 0.005 0.031 0.031 __init__.py:15( )\r\n", " 1 0.002 0.002 0.017 0.017 __init__.py:7( )\r\n", " 1 0.007 0.007 0.015 0.015 numeric.py:1( )\r\n", " 1 0.003 0.003 0.014 0.014 __init__.py:45( )\r\n", " 275 0.006 0.000 0.008 0.000 function_base.py:2940(add_newdoc)\r\n", " 1 0.006 0.006 0.007 0.007 __init__.py:88( )\r\n", " 1 0.005 0.005 0.006 0.006 __init__.py:38( )\r\n", " 1 0.004 0.004 0.006 0.006 npyio.py:1( )\r\n", " 1 0.002 0.002 0.006 0.006 index_tricks.py:1( )\r\n", " 1 0.005 0.005 0.005 0.005 polynomial.py:55( )\r\n", " 1 0.003 0.003 0.005 0.005 collections.py:1( )\r\n", " 1 0.004 0.004 0.005 0.005 legendre.py:83( )\r\n", " 1 0.002 0.002 0.005 0.005 ctypeslib.py:51( )\r\n", " 1 0.004 0.004 0.004 0.004 chebyshev.py:87( )\r\n", " 1 0.003 0.003 0.004 0.004 case.py:1( )\r\n", " 301 0.004 0.000 0.004 0.000 {method 'reduce' of 'numpy.ufunc' objects}\r\n", " 100 0.003 0.000 0.004 0.000 linalg.py:214(_assertFinite)\r\n", " 1 0.003 0.003 0.004 0.004 laguerre.py:59( )\r\n", " 200 0.000 0.000 0.004 0.000 {method 'all' of 'numpy.ndarray' objects}\r\n", " 1 0.003 0.003 0.004 0.004 hermite.py:59( )\r\n", " 6 0.000 0.000 0.004 0.001 string.py:148(substitute)\r\n", " 1 0.003 0.003 0.004 0.004 hermite_e.py:59( )\r\n", " 6 0.003 0.000 0.004 0.001 {method 'sub' of '_sre.SRE_Pattern' objects}\r\n", " 100 0.000 0.000 0.003 0.000 fromnumeric.py:1837(all)\r\n", " 200 0.000 0.000 0.003 0.000 _methods.py:35(_all)\r\n", " 1 0.000 0.000 0.003 0.003 polynomial.py:4( )\r\n", " 13 0.000 0.000 0.003 0.000 re.py:188(compile)\r\n", " 13 0.000 0.000 0.003 0.000 re.py:226(_compile)\r\n", " 1 0.003 0.003 0.003 0.003 __init__.py:4( )\r\n", " 1 0.000 0.000 0.003 0.003 _internal.py:6( )\r\n", " 11 0.000 0.000 0.003 0.000 sre_compile.py:496(compile)\r\n", " 1 0.002 0.002 0.003 0.003 result.py:1( )\r\n", " 2 0.002 0.001 0.002 0.001 function_base.py:1( )\r\n", " 1 0.001 0.001 0.002 0.002 __init__.py:44( )\r\n", " 1 0.001 0.001 0.002 0.002 main.py:1( )\r\n", " 1 0.001 0.001 0.002 0.002 _datasource.py:33( )\r\n", " 1 0.002 0.002 0.002 0.002 arrayprint.py:5( )\r\n", " 1 0.002 0.002 0.002 0.002 heapq.py:31( )\r\n", " 1 0.002 0.002 0.002 0.002 runner.py:1( )\r\n", " 1 0.000 0.000 0.002 0.002 numerictypes.py:82( )\r\n", " 1 0.001 0.001 0.002 0.002 core.py:21( )\r\n", " 2 0.001 0.001 0.002 0.001 collections.py:282(namedtuple)\r\n", " 11 0.000 0.000 0.001 0.000 sre_parse.py:676(parse)\r\n", " 11 0.000 0.000 0.001 0.000 sre_compile.py:481(_code)\r\n", " 17/11 0.000 0.000 0.001 0.000 sre_parse.py:302(_parse_sub)\r\n", " 100 0.000 0.000 0.001 0.000 {method 'max' of 'numpy.ndarray' objects}\r\n", " 1 0.001 0.001 0.001 0.001 linalg.py:10( )\r\n", " 17/11 0.001 0.000 0.001 0.000 sre_parse.py:380(_parse)\r\n", " 1 0.001 0.001 0.001 0.001 __init__.py:10( )\r\n", " 101 0.000 0.000 0.001 0.000 _methods.py:15(_amax)\r\n", " 1 0.000 0.000 0.001 0.001 difflib.py:29( )\r\n", " 1 0.001 0.001 0.001 0.001 __init__.py:3( )\r\n", " 38/11 0.000 0.000 0.001 0.000 sre_compile.py:33(_compile)\r\n", " 1 0.001 0.001 0.001 0.001 shutil.py:5( )\r\n", " 1 0.001 0.001 0.001 0.001 loader.py:1( )\r\n", " 100 0.001 0.000 0.001 0.000 linalg.py:139(_commonType)\r\n", " 300 0.000 0.000 0.001 0.000 linalg.py:111(isComplexType)\r\n", " 100 0.000 0.000 0.001 0.000 numeric.py:462(asanyarray)\r\n", " 1 0.000 0.000 0.001 0.001 util.py:1( )\r\n", " 3 0.000 0.000 0.001 0.000 warnings.py:45(filterwarnings)\r\n", " 238 0.001 0.000 0.001 0.000 {numpy.core.multiarray.array}\r\n", " 1 0.001 0.001 0.001 0.001 utils.py:4( )\r\n", " 100 0.001 0.000 0.001 0.000 {method 'astype' of 'numpy.ndarray' objects}\r\n", " 1 0.001 0.001 0.001 0.001 fromnumeric.py:3( )\r\n", " 666 0.001 0.000 0.001 0.000 string.py:158(convert)\r\n", " 40 0.000 0.000 0.001 0.000 core.py:109(get_object_signature)\r\n", " 100 0.000 0.000 0.001 0.000 linalg.py:106(_makearray)\r\n", " 15 0.000 0.000 0.001 0.000 sre_compile.py:179(_compile_charset)\r\n", " 1 0.000 0.000 0.001 0.001 numerictypes.py:304(_add_aliases)\r\n", " 429 0.001 0.000 0.001 0.000 {issubclass}\r\n", " 15 0.000 0.000 0.000 0.000 sre_compile.py:208(_optimize_charset)\r\n", " 23 0.000 0.000 0.000 0.000 core.py:5983(__init__)\r\n", " 23 0.000 0.000 0.000 0.000 core.py:5988(getdoc)\r\n", " 1 0.000 0.000 0.000 0.000 utils.py:1( )\r\n", " 1 0.000 0.000 0.000 0.000 fftpack.py:32( )\r\n", " 100 0.000 0.000 0.000 0.000 linalg.py:209(_assertNdSquareness)\r\n", " 100 0.000 0.000 0.000 0.000 linalg.py:101(get_linalg_error_extobj)\r\n", " 243 0.000 0.000 0.000 0.000 sre_parse.py:202(get)\r\n", " 11 0.000 0.000 0.000 0.000 sre_compile.py:362(_compile_info)\r\n", " 285 0.000 0.000 0.000 0.000 sre_parse.py:183(__next)\r\n", " 932 0.000 0.000 0.000 0.000 {isinstance}\r\n", " 509 0.000 0.000 0.000 0.000 {getattr}\r\n", " 1 0.000 0.000 0.000 0.000 defmatrix.py:1( )\r\n", " 1 0.000 0.000 0.000 0.000 extras.py:10( )\r\n", " 40 0.000 0.000 0.000 0.000 _inspect.py:120(getargspec)\r\n", " 100 0.000 0.000 0.000 0.000 numeric.py:392(asarray)\r\n", " 100 0.000 0.000 0.000 0.000 linalg.py:219(_assertNoEmpty2d)\r\n", " 26 0.000 0.000 0.000 0.000 numerictypes.py:232(bitname)\r\n", " 59/32 0.000 0.000 0.000 0.000 sre_parse.py:141(getwidth)\r\n", " 31 0.000 0.000 0.000 0.000 _inspect.py:159(formatargspec)\r\n", " 1 0.000 0.000 0.000 0.000 _iotools.py:3( )\r\n", " 19 0.000 0.000 0.000 0.000 nosetester.py:140(__init__)\r\n", " 3 0.000 0.000 0.000 0.000 numeric.py:346(extend_all)\r\n", " 100 0.000 0.000 0.000 0.000 linalg.py:198(_assertRankAtLeast2)\r\n", " 272 0.000 0.000 0.000 0.000 {method 'strip' of 'str' objects}\r\n", " 100 0.000 0.000 0.000 0.000 linalg.py:127(_complexType)\r\n", " 4 0.000 0.000 0.000 0.000 sre_compile.py:259(_mk_bitmap)\r\n", " 1429 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects}\r\n", " 1 0.000 0.000 0.000 0.000 case.py:133(TestCase)\r\n", " 1 0.000 0.000 0.000 0.000 polyutils.py:33( )\r\n", " 145 0.000 0.000 0.000 0.000 sre_parse.py:131(__getitem__)\r\n", " 9 0.000 0.000 0.000 0.000 extras.py:241(__init__)\r\n", " 9 0.000 0.000 0.000 0.000 extras.py:245(getdoc)\r\n", " 272 0.000 0.000 0.000 0.000 {numpy.lib._compiled_base.add_docstring}\r\n", " 8 0.000 0.000 0.000 0.000 core.py:7190(__init__)\r\n", " 27 0.000 0.000 0.000 0.000 core.py:822(__init__)\r\n", " 31 0.000 0.000 0.000 0.000 _inspect.py:61(getargs)\r\n", " 1 0.000 0.000 0.000 0.000 numerictypes.py:458(_set_array_types)\r\n", " 1 0.000 0.000 0.000 0.000 numerictypes.py:288(_add_types)\r\n", " 8 0.000 0.000 0.000 0.000 core.py:7195(getdoc)\r\n", "1031/1009 0.000 0.000 0.000 0.000 {len}\r\n", " 100 0.000 0.000 0.000 0.000 {max}\r\n", " 1 0.000 0.000 0.000 0.000 records.py:36( )\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:265(_reset_cache)\r\n", " 906 0.000 0.000 0.000 0.000 {method 'group' of '_sre.SRE_Match' objects}\r\n", " 100 0.000 0.000 0.000 0.000 linalg.py:124(_realType)\r\n", " 19 0.000 0.000 0.000 0.000 posixpath.py:127(dirname)\r\n", " 273 0.000 0.000 0.000 0.000 {method 'get' of 'dict' objects}\r\n", " 1 0.000 0.000 0.000 0.000 defchararray.py:17( )\r\n", " 1 0.000 0.000 0.000 0.000 :2( )\r\n", " 1 0.000 0.000 0.000 0.000 signals.py:1( )\r\n", " 1 0.000 0.000 0.000 0.000 suite.py:1( )\r\n", " 8 0.000 0.000 0.000 0.000 {all}\r\n", " 512 0.000 0.000 0.000 0.000 {chr}\r\n", " 51 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects}\r\n", " 46 0.000 0.000 0.000 0.000 collections.py:323( )\r\n", " 1 0.000 0.000 0.000 0.000 _endian.py:4( )\r\n", " 30 0.000 0.000 0.000 0.000 numerictypes.py:450(_add_array_type)\r\n", " 3 0.000 0.000 0.000 0.000 __init__.py:78(CFUNCTYPE)\r\n", " 1 0.000 0.000 0.000 0.000 numerictypes.py:345(_add_integer_aliases)\r\n", " 1 0.000 0.000 0.000 0.000 numerictypes.py:787(_construct_lookups)\r\n", " 21 0.000 0.000 0.000 0.000 numerictypes.py:219(_evalname)\r\n", " 1 0.000 0.000 0.000 0.000 arrayterator.py:9( )\r\n", " 18 0.000 0.000 0.000 0.000 core.py:902(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 memmap.py:1( )\r\n", " 1 0.000 0.000 0.000 0.000 core.py:2563(MaskedArray)\r\n", " 14 0.000 0.000 0.000 0.000 __init__.py:147(_check_size)\r\n", " 112 0.000 0.000 0.000 0.000 sre_parse.py:196(match)\r\n", " 1 0.000 0.000 0.000 0.000 _import_tools.py:1( )\r\n", " 115 0.000 0.000 0.000 0.000 sre_parse.py:139(append)\r\n", " 72 0.000 0.000 0.000 0.000 numerictypes.py:130(english_lower)\r\n", " 3 0.000 0.000 0.000 0.000 __init__.py:493(PYFUNCTYPE)\r\n", " 1 0.000 0.000 0.000 0.000 scimath.py:17( )\r\n", " 176 0.000 0.000 0.000 0.000 {min}\r\n", " 40 0.000 0.000 0.000 0.000 _inspect.py:15(ismethod)\r\n", " 1 0.000 0.000 0.000 0.000 getlimits.py:3( )\r\n", " 1 0.000 0.000 0.000 0.000 nanfunctions.py:20( )\r\n", " 21 0.000 0.000 0.000 0.000 sre_compile.py:355(_simple)\r\n", " 1 0.000 0.000 0.000 0.000 machar.py:7( )\r\n", " 74 0.000 0.000 0.000 0.000 _inspect.py:152(strseq)\r\n", " 1 0.000 0.000 0.000 0.000 linalg.py:76(_determine_error_states)\r\n", " 12 0.000 0.000 0.000 0.000 ctypeslib.py:303(prep_simple)\r\n", " 11 0.000 0.000 0.000 0.000 sre_parse.py:179(__init__)\r\n", " 2 0.000 0.000 0.000 0.000 shape_base.py:1( )\r\n", " 14 0.000 0.000 0.000 0.000 {method 'format' of 'str' objects}\r\n", " 2 0.000 0.000 0.000 0.000 {_ctypes.POINTER}\r\n", " 1 0.000 0.000 0.000 0.000 nosetester.py:6( )\r\n", " 1 0.000 0.000 0.000 0.000 fromnumeric.py:2043(amax)\r\n", " 1 0.000 0.000 0.000 0.000 numerictypes.py:435(_construct_char_code_lookup)\r\n", " 1 0.000 0.000 0.000 0.000 numpytest.py:1( )\r\n", " 1 0.000 0.000 0.000 0.000 result.py:26(TestResult)\r\n", " 75 0.000 0.000 0.000 0.000 {range}\r\n", " 2 0.000 0.000 0.000 0.000 utils.py:152(deprecate)\r\n", " 1 0.000 0.000 0.000 0.000 :7(Laguerre)\r\n", " 3 0.000 0.000 0.000 0.000 result.py:14(failfast)\r\n", " 91 0.000 0.000 0.000 0.000 {_sre.getlower}\r\n", " 85 0.000 0.000 0.000 0.000 sre_parse.py:127(__len__)\r\n", " 1 0.000 0.000 0.000 0.000 arraypad.py:5( )\r\n", " 21 0.000 0.000 0.000 0.000 {numpy.core.multiarray.empty}\r\n", " 1 0.000 0.000 0.000 0.000 stride_tricks.py:7( )\r\n", " 40 0.000 0.000 0.000 0.000 numerictypes.py:157(english_upper)\r\n", " 1 0.000 0.000 0.000 0.000 defchararray.py:1668(chararray)\r\n", " 112 0.000 0.000 0.000 0.000 {method 'translate' of 'str' objects}\r\n", " 14 0.000 0.000 0.000 0.000 numerictypes.py:184(english_capitalize)\r\n", " 1 0.000 0.000 0.000 0.000 _methods.py:5( )\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:349(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 numerictypes.py:386(_set_up_aliases)\r\n", " 6 0.000 0.000 0.000 0.000 core.py:1046(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 _iotools.py:466(StringConverter)\r\n", " 1 0.000 0.000 0.000 0.000 format.py:136( )\r\n", " 1 0.000 0.000 0.000 0.000 :7(Legendre)\r\n", " 1 0.000 0.000 0.000 0.000 :7(Polynomial)\r\n", " 8 0.000 0.000 0.000 0.000 collections.py:349( )\r\n", " 124 0.000 0.000 0.000 0.000 {method 'startswith' of 'str' objects}\r\n", " 1 0.000 0.000 0.000 0.000 :7(HermiteE)\r\n", " 11 0.000 0.000 0.000 0.000 {_sre.compile}\r\n", " 1 0.000 0.000 0.000 0.000 :7(Hermite)\r\n", " 2 0.000 0.000 0.000 0.000 utils.py:108(__call__)\r\n", " 1 0.000 0.000 0.000 0.000 :7(Chebyshev)\r\n", " 43 0.000 0.000 0.000 0.000 _inspect.py:163( )\r\n", " 3 0.000 0.000 0.000 0.000 functools.py:17(update_wrapper)\r\n", " 38 0.000 0.000 0.000 0.000 sre_parse.py:91(__init__)\r\n", " 9 0.000 0.000 0.000 0.000 core.py:2419(__init__)\r\n", " 11 0.000 0.000 0.000 0.000 sre_parse.py:258(_escape)\r\n", " 1 0.000 0.000 0.000 0.000 _inspect.py:7( )\r\n", " 19 0.000 0.000 0.000 0.000 {method 'rfind' of 'str' objects}\r\n", " 22 0.000 0.000 0.000 0.000 sre_compile.py:475(isstring)\r\n", " 1 0.000 0.000 0.000 0.000 __future__.py:48( )\r\n", " 1 0.000 0.000 0.000 0.000 pprint.py:35( )\r\n", " 17 0.000 0.000 0.000 0.000 {method 'keys' of 'dict' objects}\r\n", " 1 0.000 0.000 0.000 0.000 StringIO.py:30( )\r\n", " 4 0.000 0.000 0.000 0.000 sre_parse.py:217(isname)\r\n", " 40 0.000 0.000 0.000 0.000 _inspect.py:26(isfunction)\r\n", " 1 0.000 0.000 0.000 0.000 twodim_base.py:3( )\r\n", " 1 0.000 0.000 0.000 0.000 financial.py:10( )\r\n", " 18 0.000 0.000 0.000 0.000 {_struct.calcsize}\r\n", " 126 0.000 0.000 0.000 0.000 {ord}\r\n", " 45 0.000 0.000 0.000 0.000 {repr}\r\n", " 2 0.000 0.000 0.000 0.000 numeric.py:2320(seterr)\r\n", " 1 0.000 0.000 0.000 0.000 defmatrix.py:206(matrix)\r\n", " 1 0.000 0.000 0.000 0.000 collections.py:26(OrderedDict)\r\n", " 2 0.000 0.000 0.000 0.000 getlimits.py:244(__init__)\r\n", " 15 0.000 0.000 0.000 0.000 sre_compile.py:52(fixup)\r\n", " 1 0.000 0.000 0.000 0.000 numeric.py:2705(__enter__)\r\n", " 1 0.000 0.000 0.000 0.000 numeric.py:2716(_setdef)\r\n", " 1 0.000 0.000 0.000 0.000 polytemplate.py:11( )\r\n", " 1 0.000 0.000 0.000 0.000 {posix.uname}\r\n", " 9 0.000 0.000 0.000 0.000 core.py:2425(getdoc)\r\n", " 21 0.000 0.000 0.000 0.000 {sys._getframe}\r\n", " 3 0.000 0.000 0.000 0.000 {numpy.core.umath.seterrobj}\r\n", " 18 0.000 0.000 0.000 0.000 {method 'extend' of 'list' objects}\r\n", " 2 0.000 0.000 0.000 0.000 numeric.py:1617(set_string_function)\r\n", " 38 0.000 0.000 0.000 0.000 {method 'isalnum' of 'str' objects}\r\n", " 19 0.000 0.000 0.000 0.000 {method 'rstrip' of 'str' objects}\r\n", " 8 0.000 0.000 0.000 0.000 collections.py:347( )\r\n", " 31 0.000 0.000 0.000 0.000 _inspect.py:39(iscode)\r\n", " 1 0.000 0.000 0.000 0.000 py3k.py:4( )\r\n", " 1 0.000 0.000 0.000 0.000 helper.py:4( )\r\n", " 1 0.000 0.000 0.000 0.000 arraysetops.py:26( )\r\n", " 1 0.000 0.000 0.000 0.000 keyword.py:11( )\r\n", " 1 0.000 0.000 0.000 0.000 decorators.py:15( )\r\n", " 2 0.000 0.000 0.000 0.000 getlimits.py:269(max)\r\n", " 1 0.000 0.000 0.000 0.000 _internal.py:196(_getintp_ctype)\r\n", " 1 0.000 0.000 0.000 0.000 info.py:176( )\r\n", " 5 0.000 0.000 0.000 0.000 sre_parse.py:73(opengroup)\r\n", " 9 0.000 0.000 0.000 0.000 {method 'update' of 'dict' objects}\r\n", " 1 0.000 0.000 0.000 0.000 info.py:147( )\r\n", " 1 0.000 0.000 0.000 0.000 :1(Mismatch)\r\n", " 11 0.000 0.000 0.000 0.000 sre_parse.py:68(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 polynomial.py:930(poly1d)\r\n", " 1 0.000 0.000 0.000 0.000 :1(Match)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:5758(__new__)\r\n", " 2 0.000 0.000 0.000 0.000 {numpy.core.multiarray.set_string_function}\r\n", " 1 0.000 0.000 0.000 0.000 info.py:84( )\r\n", " 1 0.000 0.000 0.000 0.000 extras.py:1501(__init__)\r\n", " 13 0.000 0.000 0.000 0.000 {method 'items' of 'dict' objects}\r\n", " 50 0.000 0.000 0.000 0.000 {_ctypes.sizeof}\r\n", " 21 0.000 0.000 0.000 0.000 sre_parse.py:135(__setitem__)\r\n", " 1 0.000 0.000 0.000 0.000 _iotools.py:246(NameValidator)\r\n", " 1 0.000 0.000 0.000 0.000 ufunclike.py:5( )\r\n", " 2 0.000 0.000 0.000 0.000 numeric.py:2416(geterr)\r\n", " 3 0.000 0.000 0.000 0.000 index_tricks.py:231(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 copy_reg.py:14(pickle)\r\n", " 2 0.000 0.000 0.000 0.000 {map}\r\n", " 5 0.000 0.000 0.000 0.000 sre_parse.py:84(closegroup)\r\n", " 1 0.000 0.000 0.000 0.000 info.py:83( )\r\n", " 1 0.000 0.000 0.000 0.000 extras.py:1431(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 {method 'view' of 'numpy.ndarray' objects}\r\n", " 1 0.000 0.000 0.000 0.000 getlimits.py:194(iinfo)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:5752(MaskedConstant)\r\n", " 1 0.000 0.000 0.000 0.000 numeric.py:2701(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 numeric.py:2710(__exit__)\r\n", " 1 0.000 0.000 0.000 0.000 _internal.py:224(_ctypes)\r\n", " 4 0.000 0.000 0.000 0.000 {method 'replace' of 'str' objects}\r\n", " 1 0.000 0.000 0.000 0.000 npyio.py:90(BagObj)\r\n", " 1 0.000 0.000 0.000 0.000 _datasource.py:49(_FileOpeners)\r\n", " 1 0.000 0.000 0.000 0.000 arrayterator.py:21(Arrayterator)\r\n", " 1 0.000 0.000 0.000 0.000 utils.py:957(SafeEval)\r\n", " 1 0.000 0.000 0.000 0.000 nosetester.py:88(NoseTester)\r\n", " 1 0.000 0.000 0.000 0.000 warnings.py:74(simplefilter)\r\n", " 1 0.000 0.000 0.000 0.000 warnings.py:339(__enter__)\r\n", " 4 0.000 0.000 0.000 0.000 core.py:92(doc_note)\r\n", " 1 0.000 0.000 0.000 0.000 records.py:286(recarray)\r\n", " 1 0.000 0.000 0.000 0.000 _import_tools.py:8(PackageLoader)\r\n", " 1 0.000 0.000 0.000 0.000 StringIO.py:42(StringIO)\r\n", " 3 0.000 0.000 0.000 0.000 functools.py:39(wraps)\r\n", " 1 0.000 0.000 0.000 0.000 info.py:34( )\r\n", " 1 0.000 0.000 0.000 0.000 index_tricks.py:461(ndenumerate)\r\n", " 1 0.000 0.000 0.000 0.000 weakref.py:243(__init__)\r\n", " 24 0.000 0.000 0.000 0.000 sre_parse.py:211(isident)\r\n", " 1 0.000 0.000 0.000 0.000 npyio.py:133(NpzFile)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:2241(_MaskedPrintOption)\r\n", " 1 0.000 0.000 0.000 0.000 fnmatch.py:11( )\r\n", " 67 0.000 0.000 0.000 0.000 {globals}\r\n", " 1 0.000 0.000 0.000 0.000 _datasource.py:150(DataSource)\r\n", " 1 0.000 0.000 0.000 0.000 runner.py:28(TextTestResult)\r\n", " 3 0.000 0.000 0.000 0.000 {method 'split' of 'str' objects}\r\n", " 1 0.000 0.000 0.000 0.000 numerictypes.py:772(_typedict)\r\n", " 1 0.000 0.000 0.000 0.000 {_ctypes.set_conversion_mode}\r\n", " 38 0.000 0.000 0.000 0.000 sre_compile.py:25(_identityfunction)\r\n", " 1 0.000 0.000 0.000 0.000 function_base.py:1405(vectorize)\r\n", " 1 0.000 0.000 0.000 0.000 suite.py:16(BaseTestSuite)\r\n", " 7 0.000 0.000 0.000 0.000 case.py:609(_deprecate)\r\n", " 1 0.000 0.000 0.000 0.000 index_tricks.py:434(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 warnings.py:318(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 collections.py:381(Counter)\r\n", " 1 0.000 0.000 0.000 0.000 UserDict.py:58(get)\r\n", " 1 0.000 0.000 0.000 0.000 index_tricks.py:456(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 _datasource.py:497(Repository)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:5555(mvoid)\r\n", " 1 0.000 0.000 0.000 0.000 arrayprint.py:715(DatetimeFormat)\r\n", " 9 0.000 0.000 0.000 0.000 {setattr}\r\n", " 1 0.000 0.000 0.000 0.000 ctypeslib.py:150(_ndptr)\r\n", " 1 0.000 0.000 0.000 0.000 _iotools.py:155(LineSplitter)\r\n", " 1 0.000 0.000 0.000 0.000 case.py:1018(FunctionTestCase)\r\n", " 1 0.000 0.000 0.000 0.000 difflib.py:46(SequenceMatcher)\r\n", " 1 0.000 0.000 0.000 0.000 warnings.py:355(__exit__)\r\n", " 1 0.000 0.000 0.000 0.000 loader.py:38(TestLoader)\r\n", " 1 0.000 0.000 0.000 0.000 __config__.py:3( )\r\n", " 1 0.000 0.000 0.000 0.000 difflib.py:1672(HtmlDiff)\r\n", " 1 0.000 0.000 0.000 0.000 :1( )\r\n", " 4 0.000 0.000 0.000 0.000 {method 'insert' of 'list' objects}\r\n", " 6 0.000 0.000 0.000 0.000 core.py:769(__init__)\r\n", " 8 0.000 0.000 0.000 0.000 {method '__contains__' of 'frozenset' objects}\r\n", " 1 0.000 0.000 0.000 0.000 utils.py:1398(WarningManager)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:5919(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 version.py:3( )\r\n", " 2 0.000 0.000 0.000 0.000 utils.py:103(__init__)\r\n", " 3 0.000 0.000 0.000 0.000 __init__.py:494(CFunctionType)\r\n", " 1 0.000 0.000 0.000 0.000 pprint.py:84(PrettyPrinter)\r\n", " 1 0.000 0.000 0.000 0.000 runner.py:119(TextTestRunner)\r\n", " 1 0.000 0.000 0.000 0.000 __future__.py:74(_Feature)\r\n", " 1 0.000 0.000 0.000 0.000 _datasource.py:72(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 arrayprint.py:532(FloatFormat)\r\n", " 7 0.000 0.000 0.000 0.000 {method 'pop' of 'dict' objects}\r\n", " 1 0.000 0.000 0.000 0.000 records.py:85(format_parser)\r\n", " 1 0.000 0.000 0.000 0.000 main.py:63(TestProgram)\r\n", " 2 0.000 0.000 0.000 0.000 sre_parse.py:214(isdigit)\r\n", " 6 0.000 0.000 0.000 0.000 {numpy.core.umath.geterrobj}\r\n", " 2 0.000 0.000 0.000 0.000 index_tricks.py:626(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 index_tricks.py:213(AxisConcatenator)\r\n", " 1 0.000 0.000 0.000 0.000 arrayprint.py:658(LongFloatFormat)\r\n", " 3 0.000 0.000 0.000 0.000 __init__.py:104(CFunctionType)\r\n", " 1 0.000 0.000 0.000 0.000 {zip}\r\n", " 1 0.000 0.000 0.000 0.000 records.py:216(record)\r\n", " 1 0.000 0.000 0.000 0.000 difflib.py:766(Differ)\r\n", " 4 0.000 0.000 0.000 0.000 core.py:2432(__get__)\r\n", " 1 0.000 0.000 0.000 0.000 memmap.py:23(memmap)\r\n", " 1 0.000 0.000 0.000 0.000 {_ctypes.dlopen}\r\n", " 1 0.000 0.000 0.000 0.000 index_tricks.py:85(nd_grid)\r\n", " 1 0.000 0.000 0.000 0.000 machar.py:17(MachAr)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:5931(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:332(CDLL)\r\n", " 1 0.000 0.000 0.000 0.000 arrayprint.py:743(TimedeltaFormat)\r\n", " 1 0.000 0.000 0.000 0.000 polyutils.py:48(RankWarning)\r\n", " 1 0.000 0.000 0.000 0.000 {numpy.core.multiarray.set_typeDict}\r\n", " 1 0.000 0.000 0.000 0.000 stride_tricks.py:14(DummyArray)\r\n", " 1 0.000 0.000 0.000 0.000 getlimits.py:24(finfo)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:5973(_frommethod)\r\n", " 1 0.000 0.000 0.000 0.000 suite.py:252(_ErrorHolder)\r\n", " 1 0.000 0.000 0.000 0.000 arrayprint.py:688(LongComplexFormat)\r\n", " 1 0.000 0.000 0.000 0.000 case.py:45(_UnexpectedSuccess)\r\n", " 3 0.000 0.000 0.000 0.000 core.py:784(__init__)\r\n", " 2 0.000 0.000 0.000 0.000 index_tricks.py:145(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 numeric.py:2639(errstate)\r\n", " 1 0.000 0.000 0.000 0.000 utils.py:1366(WarningMessage)\r\n", " 1 0.000 0.000 0.000 0.000 shutil.py:34(SpecialFileError)\r\n", " 1 0.000 0.000 0.000 0.000 _iotools.py:438(ConverterError)\r\n", " 1 0.000 0.000 0.000 0.000 extras.py:224(_fromnxfunction)\r\n", " 1 0.000 0.000 0.000 0.000 signals.py:9(_InterruptHandler)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:243(c_char_p)\r\n", " 1 0.000 0.000 0.000 0.000 string.py:131(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:233(c_byte)\r\n", " 1 0.000 0.000 0.000 0.000 index_tricks.py:439(CClass)\r\n", " 1 0.000 0.000 0.000 0.000 nanfunctions.py:31(NanWarning)\r\n", " 1 0.000 0.000 0.000 0.000 index_tricks.py:510(ndindex)\r\n", " 2 0.000 0.000 0.000 0.000 {hasattr}\r\n", " 1 0.000 0.000 0.000 0.000 runner.py:12(_WritelnDecorator)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:7178(_convert2ma)\r\n", " 1 0.000 0.000 0.000 0.000 linalg.py:43(LinAlgError)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:428(LibraryLoader)\r\n", " 1 0.000 0.000 0.000 0.000 case.py:98(_AssertRaisesContext)\r\n", " 1 0.000 0.000 0.000 0.000 UserDict.py:70(__contains__)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:159(py_object)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:112(ModuleDeprecationWarning)\r\n", " 1 0.000 0.000 0.000 0.000 case.py:25(SkipTest)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:883(_MaskedBinaryOperation)\r\n", " 1 0.000 0.000 0.000 0.000 _iotools.py:445(ConverterLockError)\r\n", " 2 0.000 0.000 0.000 0.000 utils.py:87(_set_function_name)\r\n", " 1 0.000 0.000 0.000 0.000 copy_reg.py:27(constructor)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:782(_DomainGreater)\r\n", " 1 0.000 0.000 0.000 0.000 suite.py:78(TestSuite)\r\n", " 7 0.000 0.000 0.000 0.000 __future__.py:75(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:260(c_bool)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:388(PyDLL)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:193(c_uint)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:255(c_void_p)\r\n", " 1 0.000 0.000 0.000 0.000 index_tricks.py:583(IndexExpression)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:359(_FuncPtr)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:5917(_minimum_operation)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:238(c_char)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:767(_DomainSafeDivide)\r\n", " 1 0.000 0.000 0.000 0.000 _endian.py:49(BigEndianStructure)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:1026(_DomainedBinaryOperation)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:2390(_arraymethod)\r\n", " 1 0.000 0.000 0.000 0.000 numeric.py:49(ComplexWarning)\r\n", " 1 0.000 0.000 0.000 0.000 arrayprint.py:699(ComplexFormat)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:729(_DomainCheckInterval)\r\n", " 1 0.000 0.000 0.000 0.000 shutil.py:31(Error)\r\n", " 2 0.000 0.000 0.000 0.000 __init__.py:429(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:128(MAError)\r\n", " 1 0.000 0.000 0.000 0.000 _internal.py:217(_missing_ctypes)\r\n", " 3 0.000 0.000 0.000 0.000 _inspect.py:161( )\r\n", " 1 0.000 0.000 0.000 0.000 suite.py:299(_DebugResult)\r\n", " 1 0.000 0.000 0.000 0.000 case.py:34(_ExpectedFailure)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:2460(MaskedIterator)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:5862(_extrema_operation)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:205(c_longdouble)\r\n", " 1 0.000 0.000 0.000 0.000 _import_tools.py:336(PackageLoaderDebug)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:131(MaskError)\r\n", " 1 0.000 0.000 0.000 0.000 shutil.py:38(ExecError)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:291(c_wchar_p)\r\n", " 1 0.000 0.000 0.000 0.000 polyutils.py:52(PolyError)\r\n", " 2 0.000 0.000 0.000 0.000 core.py:796(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:294(c_wchar)\r\n", " 1 0.000 0.000 0.000 0.000 utils.py:1581(IgnoreException)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:226(c_ubyte)\r\n", " 1 0.000 0.000 0.000 0.000 index_tricks.py:340(RClass)\r\n", " 1 0.000 0.000 0.000 0.000 polynomial.py:21(RankWarning)\r\n", " 1 0.000 0.000 0.000 0.000 numeric.py:2635(_unspecified)\r\n", " 1 0.000 0.000 0.000 0.000 polyutils.py:69(PolyBase)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:805(_MaskedUnaryOperation)\r\n", " 2 0.000 0.000 0.000 0.000 {method 'clear' of 'dict' objects}\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:197(c_float)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:172(c_ushort)\r\n", " 1 0.000 0.000 0.000 0.000 _iotools.py:452(ConversionWarning)\r\n", " 8 0.000 0.000 0.000 0.000 {method 'isdigit' of 'str' objects}\r\n", " 1 0.000 0.000 0.000 0.000 core.py:751(_DomainTan)\r\n", " 6 0.000 0.000 0.000 0.000 {method 'add' of 'set' objects}\r\n", " 1 0.000 0.000 0.000 0.000 core.py:2246(__init__)\r\n", " 3 0.000 0.000 0.000 0.000 core.py:737(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 _inspect.py:162( )\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:168(c_short)\r\n", " 1 0.000 0.000 0.000 0.000 utils.py:92(_Deprecate)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:757(__init__)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:201(c_double)\r\n", " 1 0.000 0.000 0.000 0.000 polyutils.py:56(PolyDomainError)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:189(c_int)\r\n", " 1 0.000 0.000 0.000 0.000 _endian.py:26(_swapped_meta)\r\n", " 1 0.000 0.000 0.000 0.000 extras.py:1485(mr_class)\r\n", " 1 0.000 0.000 0.000 0.000 arrayprint.py:638(IntegerFormat)\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:180(c_ulong)\r\n", " 1 0.000 0.000 0.000 0.000 extras.py:1419(MAxisConcatenator)\r\n", " 5 0.000 0.000 0.000 0.000 {method 'remove' of 'list' objects}\r\n", " 1 0.000 0.000 0.000 0.000 __init__.py:176(c_long)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:5761(__array_finalize__)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:794(_DomainGreaterEqual)\r\n", " 1 0.000 0.000 0.000 0.000 core.py:5929(_maximum_operation)\r\n", " 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}\r\n", "\r\n", "\r\n" ] } ], "prompt_number": 84 }, { "cell_type": "markdown", "metadata": {}, "source": [ "- \uc2e4\ud589\ud574\ubcf4\uba74 \ud568\uc218 \uc774\ub984 \uc21c\uc73c\ub85c \uc815\ub82c\ub41c \uacb0\uacfc \ucd9c\ub825\n", "- \uc5b4\ub514\uc5d0\uc11c \uac00\uc7a5 \ub9ce\uc740 \uc2dc\uac04\uc774 \uc18c\uc694\ub418\uc5c8\ub294\uc9c0 \uc54c\uae30 \uc704\ud574 -s \uc635\uc158\uc73c\ub85c \uc815\ub82c \uc21c\uc11c\ub97c \uc9c0\uc815\ud574\uc8fc\ub294 \uac83\uc774 \uc77c\ubc18\uc801\uc778 \ubc29\ubc95\n", "- cumtime \uc5f4\uc744 \ud6d1\uc5b4\ubcf4\uba74\uc11c \uac01 \ud568\uc218 \ub0b4\ubd80\uc5d0\uc11c \uc5bc\ub9c8\ub098 \ub9ce\uc740 \uc2dc\uac04\uc774 \uc18c\uc694\ub418\uc5c8\ub294\uc9c0 \ud655\uc778\n", "- \ub9cc\uc57d\uc5d0 \uc5b4\ub5a4 \ud568\uc218\uac00 \ub2e4\ub978 \ud568\uc218\ub97c \ud638\ucd9c\ud55c\ub2e4\uace0 \ud574\ub3c4 \uadf8 \ud568\uc218\uc5d0 \ub300\ud55c \uc2dc\uac04 \uce21\uc815\uc740 \uba48\ucd94\uc9c0 \uc54a\ub294\ub2e4\ub294 \uc810 \uae30\uc5b5\n", "- cProfile\uc740 \uac01 \ud568\uc218\uc758 \uc2dc\uc791\uacfc \ub05d \uc2dc\uac04\uc744 \uae30\ub85d\ud558\uc5ec \uc2dc\uac04 \uce21\uc815\n", "- cProfile\uc740 \ud504\ub85c\uadf8\ub7a8\uc744 \ub530\ub85c \uc2e4\ud589\ud558\uc9c0 \uc54a\uace0\ub3c4 \uc784\uc758\uc758 \ucf54\ub4dc \ube14\ub85d\uc744 \ud504\ub85c\uadf8\ub7a8\uc801\uc73c\ub85c \ud504\ub85c\ud30c\uc77c\ub9c1\ud558\uae30 \uc704\ud574 \uc0ac\uc6a9\n", "- %prun \uba85\ub839\uacfc %run -p \uc635\uc158 \uc81c\uacf5\n", "- %prun\uc740 cProfile\uc5d0 \uc0ac\uc6a9\ud558\ub294 \uba85\ub839\ud589 \uc635\uc158\uc744 \uadf8\ub300\ub85c \ubc1b\uc544\uc11c .py \ud30c\uc77c \ub300\uc2e0 \uc784\uc758\uc758 \ud30c\uc774\uc36c \ubb38\uc7a5\uc744 \ud504\ub85c\ud30c\uc77c\ub9c1 \ud574\uc900\ub2e4." ] }, { "cell_type": "code", "collapsed": false, "input": [ "%prun -l 7 -s cumulative run_experiment()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " " ] } ], "prompt_number": 85 }, { "cell_type": "markdown", "metadata": {}, "source": [ " 4003 function calls in 0.661 seconds\n", "\n", " Ordered by: cumulative time\n", " List reduced from 32 to 7 due to restriction <7>\n", "\n", " ncalls tottime percall cumtime percall filename:lineno(function)\n", " 1 0.000 0.000 0.661 0.661:1( )\n", " 1 0.002 0.002 0.661 0.661 :4(run_experiment)\n", " 100 0.608 0.006 0.619 0.006 linalg.py:819(eigvals)\n", " 100 0.039 0.000 0.039 0.000 {method 'randn' of 'mtrand.RandomState' objects}\n", " 100 0.003 0.000 0.004 0.000 linalg.py:214(_assertFinite)\n", " 300 0.004 0.000 0.004 0.000 {method 'reduce' of 'numpy.ufunc' objects}\n", " 200 0.000 0.000 0.003 0.000 {method 'all' of 'numpy.ndarray' objects}" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%run -p -s cumulative ch03/cprof_example.py" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Largest one we saw: 12.630078966\n", " " ] } ], "prompt_number": 86 }, { "cell_type": "markdown", "metadata": {}, "source": [ " 4072 function calls in 0.674 seconds\n", "\n", " Ordered by: cumulative time\n", "\n", " ncalls tottime percall cumtime percall filename:lineno(function)\n", " 1 0.000 0.000 0.674 0.674 :1( )\n", " 1 0.000 0.000 0.674 0.674 interactiveshell.py:2496(safe_execfile)\n", " 1 0.000 0.000 0.668 0.668 py3compat.py:219(execfile)\n", " 1 0.001 0.001 0.667 0.667 {execfile}\n", " 1 0.000 0.000 0.666 0.666 cprof_example.py:1( )\n", " 1 0.001 0.001 0.666 0.666 cprof_example.py:4(run_experiment)\n", " 100 0.618 0.006 0.627 0.006 linalg.py:819(eigvals)\n", " 100 0.037 0.000 0.037 0.000 {method 'randn' of 'mtrand.RandomState' objects}\n", " 1 0.006 0.006 0.006 0.006 posixpath.py:127(dirname)\n", " 100 0.003 0.000 0.004 0.000 linalg.py:214(_assertFinite)\n", " 301 0.003 0.000 0.003 0.000 {method 'reduce' of 'numpy.ufunc' objects}\n", " 200 0.000 0.000 0.003 0.000 {method 'all' of 'numpy.ndarray' objects}\n", " 200 0.000 0.000 0.003 0.000 _methods.py:35(_all)\n", " 100 0.000 0.000 0.002 0.000 fromnumeric.py:1837(all)\n", " 100 0.000 0.000 0.001 0.000 {method 'max' of 'numpy.ndarray' objects}\n", " 101 0.000 0.000 0.001 0.000 _methods.py:15(_amax)\n", " 100 0.000 0.000 0.001 0.000 linalg.py:139(_commonType)\n", " 100 0.000 0.000 0.001 0.000 linalg.py:106(_makearray)\n", " 300 0.000 0.000 0.001 0.000 linalg.py:111(isComplexType)\n", " 100 0.000 0.000 0.000 0.000 numeric.py:462(asanyarray)\n", " 200 0.000 0.000 0.000 0.000 {numpy.core.multiarray.array}\n", " 100 0.000 0.000 0.000 0.000 {method 'astype' of 'numpy.ndarray' objects}\n", " 400 0.000 0.000 0.000 0.000 {issubclass}\n", " 100 0.000 0.000 0.000 0.000 linalg.py:209(_assertNdSquareness)\n", " 100 0.000 0.000 0.000 0.000 linalg.py:101(get_linalg_error_extobj)\n", " 100 0.000 0.000 0.000 0.000 numeric.py:392(asarray)\n", " 100 0.000 0.000 0.000 0.000 linalg.py:219(_assertNoEmpty2d)\n", " 100 0.000 0.000 0.000 0.000 linalg.py:198(_assertRankAtLeast2)\n", " 100 0.000 0.000 0.000 0.000 linalg.py:127(_complexType)\n", " 100 0.000 0.000 0.000 0.000 linalg.py:124(_realType)\n", " 100 0.000 0.000 0.000 0.000 {max}\n", " 200 0.000 0.000 0.000 0.000 {method 'get' of 'dict' objects}\n", " 1 0.000 0.000 0.000 0.000 syspathcontext.py:54(__init__)\n", " 1 0.000 0.000 0.000 0.000 posixpath.py:350(abspath)\n", " 1 0.000 0.000 0.000 0.000 fromnumeric.py:2043(amax)\n", " 100 0.000 0.000 0.000 0.000 {getattr}\n", " 2 0.000 0.000 0.000 0.000 iostream.py:189(write)\n", " 101 0.000 0.000 0.000 0.000 {len}\n", " 106 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects}\n", " 1 0.000 0.000 0.000 0.000 syspathcontext.py:57(__enter__)\n", " 1 0.000 0.000 0.000 0.000 py3compat.py:30(cast_bytes)\n", " 1 0.000 0.000 0.000 0.000 posixpath.py:321(normpath)\n", " 100 0.000 0.000 0.000 0.000 {min}\n", " 1 0.000 0.000 0.000 0.000 {open}\n", " 1 0.000 0.000 0.000 0.000 py3compat.py:20(encode)\n", " 2 0.000 0.000 0.000 0.000 {method 'decode' of 'str' objects}\n", " 1 0.000 0.000 0.000 0.000 {posix.getcwdu}\n", " 2 0.000 0.000 0.000 0.000 {method 'encode' of 'unicode' objects}\n", " 2 0.000 0.000 0.000 0.000 utf_8.py:15(decode)\n", " 2 0.000 0.000 0.000 0.000 iostream.py:99(_check_mp_mode)\n", " 6 0.000 0.000 0.000 0.000 {isinstance}\n", " 2 0.000 0.000 0.000 0.000 {_codecs.utf_8_decode}\n", " 1 0.000 0.000 0.000 0.000 posixpath.py:68(join)\n", " 2 0.000 0.000 0.000 0.000 iostream.py:90(_is_master_process)\n", " 1 0.000 0.000 0.000 0.000 {method 'split' of 'unicode' objects}\n", " 5 0.000 0.000 0.000 0.000 {method 'startswith' of 'unicode' objects}\n", " 1 0.000 0.000 0.000 0.000 syspathcontext.py:64(__exit__)\n", " 2 0.000 0.000 0.000 0.000 {method 'write' of '_io.StringIO' objects}\n", " 1 0.000 0.000 0.000 0.000 {method 'rstrip' of 'unicode' objects}\n", " 1 0.000 0.000 0.000 0.000 {method 'insert' of 'list' objects}\n", " 2 0.000 0.000 0.000 0.000 {method 'setdefault' of 'dict' objects}\n", " 1 0.000 0.000 0.000 0.000 posixpath.py:258(expanduser)\n", " 2 0.000 0.000 0.000 0.000 {time.time}\n", " 1 0.000 0.000 0.000 0.000 {sys.getdefaultencoding}\n", " 1 0.000 0.000 0.000 0.000 {method 'rfind' of 'unicode' objects}\n", " 1 0.000 0.000 0.000 0.000 {method 'join' of 'unicode' objects}\n", " 1 0.000 0.000 0.000 0.000 {method 'endswith' of 'unicode' objects}\n", " 2 0.000 0.000 0.000 0.000 {posix.getpid}\n", " 1 0.000 0.000 0.000 0.000 {method 'remove' of 'list' objects}\n", " 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}\n", " 1 0.000 0.000 0.000 0.000 posixpath.py:59(isabs)\n", " 1 0.000 0.000 0.000 0.000 {sys.getfilesystemencoding}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- %prun\uc744 \uc0ac\uc6a9\ud55c \uac83\uacfc \ub3d9\uc77c\ud55c \uacb0\uacfc\ub97c \uc5bb\uc744 \uc218 \uc788\ub2e4.(\ubb3c\ub860 \uc77c\ubd80 \ubc14\ub010 \uac83\ub4e4\uc774 \uc788\uaca0\uc9c0\ub9cc \ud070 \ud2c0\uc5d0\uc11c\ub294 \ub3d9\uc77c\ud558\ub2e4)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 3.4.4 \ud568\uc218\uc758 \uac01 \uc904\ub9c8\ub2e4 \ud504\ub85c\ud30c\uc77c\ub9c1\ud558\uae30\n", "\n", "- %prun\uc774\ub098 \ub2e4\ub978 cProfile \uae30\ubc18\uc758 \ud504\ub85c\ud30c\uc77c\ub9c1 \uae30\ubc95\uc744 \ud1b5\ud574 \uc5bb\uc740 \uc815\ubcf4\ub85c\ub294 \ud568\uc218\uc758 \uc2e4\ud589 \uc2dc\uac04\uc5d0 \ub300\ud55c \uc804\uccb4 \uc0c1\ud669\uc744 \uc54c\uae30 \ud798\ub4e4\uac70\ub098 \ud568\uc218 \uc774\ub984\uc744 \uae30\uc900\uc73c\ub85c \uc218\uc9d1\ub41c \uacb0\uacfc\uac00 \ub108\ubb34 \ubcf5\uc7a1\ud574\uc11c \ubd84\uc11d \uc5b4\ub824\uc6c0\n", "- line_profiler(PyPI\ub098 \ub2e4\ub978 \ud328\ud0a4\uc9c0 \uad00\ub9ac \ub3c4\uad6c\ub97c \uc774\uc6a9\ud574 \uc5bb\uc74c)\ub77c\ub294 \uc791\uc740 \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \uc0ac\uc6a9\ud558\uba74 \ub41c\ub2e4.\n", "- IPython \ud655\uc7a5\uc744 \ud3ec\ud568\ud574 \ud558\ub098 \uc774\uc0c1\uc758 \ud568\uc218\ub97c \uc904\ub9c8\ub2e4 \ud504\ub85c\ud30c\uc77c\ub9c1 \ud560 \uc218 \uc788\ub294 %lprun \ub9e4\uc9c1 \ud568\uc218 \uc81c\uacf5\n", "\n", "#### line_profiler \uc0bd\uc9c8\uae30\n", "\n", "- \ucc45\uc5d0 \uc368 \uc788\ub294\ub300\ub85c \ud574\ubd24\uc9c0\ub9cc \ub3c4\uc800\ud788 \ub3d9\uc791\ud558\uc9c0 \uc54a\ub294\ub2e4.\n", "- \uc544\ubb34\ub9ac \uc124\uc815 \ud30c\uc77c\uc5d0 \ucd94\uac00\ud558\uace0 lprun\uc744 \ud574\ubcf4\uc9c0\ub9cc \uadf8\ub7f0 \ubaa8\ub4c8\uc740 \uc5c6\ub2e4\ub294 \uce5c\uc808\ud55c \uc5d0\ub7ec\ub97c \ubc49\uc5b4\uc900\ub2e4.\n", "- \uad6c\uae00\ub9c1\uc73c\ub85c\ub3c4 \uba87 \uc2dc\uac04\uc774\ub098 \ucc3e\uc544\ubd24\uc9c0\ub9cc \ubabb \ucc3e\uc558\uae30 \ub54c\ubb38\uc5d0 \uc5ec\uae30\uc5d0\uc11c\ub294 \uc2a4\ud0b5\ud558\uaca0\ub2e4. \ud639\uc2dc \ub418\ub294 \ubd84\uc740 \uc54c\ub824\uc8fc\uae30 \ubc14\ub780\ub2e4. \ub0b4\uac00 \ub0ad\ube44\ud55c \uc2dc\uac04\uc774 \uc544\uae4c\uc6cc\uc11c\ub77c\ub3c4 \ud55c \ubc88 \ud574\ubcf4\uace0 \uc2f6\ub2e4 \u3160\u3160" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3.5 IPython HTML \ub178\ud2b8\ubd81\n", "\n", "- \ub178\ud2b8\ubd81\uc5d0\ub294 \ucf54\ub4dc, \ucd9c\ub825 \uacb0\uacfc, \uadf8\ub9bc\uc744 \uc27d\uac8c \uacf5\uc720\ud560 \uc218 \uc788\ub294 JSON \ud30c\uc77c \ud615\uc2dd\uc758 .ipynb \ubb38\uc11c \uc874\uc7ac\n", "- \ucd5c\uadfc \ud30c\uc774\uc36c \ucee8\ud37c\ub7f0\uc2a4\uc5d0\uc11c\ub294 \uc774 .ipynb \ud30c\uc77c\uc744 \uc628\ub77c\uc778\uc73c\ub85c \uacf5\uc720\ud574 \ubc1c\ud45c \ud6c4\uc5d0 \ub2e4\ub978 \uc0ac\ub78c\ub3c4 \uc9c1\uc811 \uc2e4\ud589\ud574 \ubcfc \uc218 \uc788\ub3c4\ub85d \ud558\uace0 \uc788\uc9c0\ub9cc \uad6d\ub0b4\uc5d0\uc11c\ub294 \ub9ce\uc774 \uc0ac\uc6a9\ub418\uace0 \uc788\uc9c0 \uc54a\ub2e4. \n", "- \ub178\ud2b8\ubd81 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc740 \uba85\ub839\ud589\uc5d0\uc11c \uc2e4\ud589\ub418\ub294 \uacbd\ub7c9 \uc11c\ubc84 \ud504\ub85c\uc138\uc2a4\ub85c \uc2e4\ud589\n", "- \ub300\ud654\ud615 \ucef4\ud4e8\ud305\uc5d0 \ud3b8\ub9ac\ud55c \ub3c4\uad6c\uc77c \ubfd0\ub9cc \uc544\ub2c8\ub77c \uc5f0\uad6c\uc640 \uad50\uc721\uc744 \uc704\ud574 \uc7ac\uc0ac\uc6a9\uc774 \uac00\ub2a5\ud55c \uc774\uc0c1\uc801\uc778 \ub9e4\uccb4\n", "- \uc774 \ucc45\uc758 \ub300\ubd80\ubd84\uc744 IPython \ub178\ud2b8\ubd81\uc744 \uc0ac\uc6a9\ud574\uc11c \uc791\uc131" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " $ ipython notebook --pylab\n", " 2014-05-09 16:28:43.140 [NotebookApp] Using existing profile dir: u'/Users/re4lfl0w/.ipython/profile_default'\n", " 2014-05-09 16:28:43.149 [NotebookApp] Using MathJax from CDN: http://cdn.mathjax.org/mathjax/latest/MathJax.js\n", " 2014-05-09 16:28:43.168 [NotebookApp] Serving notebooks from local directory: /Users/re4lfl0w/Documents/SPSE\n", " 2014-05-09 16:28:43.168 [NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888/\n", " 2014-05-09 16:28:43.168 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- \ub300\ubd80\ubd84\uc758 \ud658\uacbd\uc5d0\uc11c\ub294 \uae30\ubcf8 \uc6f9\ube0c\ub77c\uc6b0\uc800\uac00 \uc790\ub3d9\uc73c\ub85c \uc5f4\ub9ac\uba74\uc11c \ub178\ud2b8\ubd81\uc758 \ub300\uc2dc\ubcf4\ub4dc\ub97c \ubcf4\uc5ec\uc900\ub2e4.\n", "- \uc5b4\ub5a8 \ub54c\uc5d0\ub294 \uc9c1\uc811 URL \uc785\ub825\n", "- \ube0c\ub77c\uc6b0\uc800\uc5d0 \ub178\ud2b8\ubd81\uc774 \ub098\ud0c0\ub098\uba74 \uac70\uae30\uc11c \uc0c8 \ub178\ud2b8\ubd81\uc744 \uc0dd\uc131\ud558\uace0 \uc0b4\ud3b4\ubcf4\uc790\n", "- [NotebookCloud](http://notebookcloud.appspot.com)\uc744 \uc774\uc6a9\ud558\uba74 EC2 \uc704\uc5d0\uc11c \ub178\ud2b8\ubd81\uc744 \uc27d\uac8c \uc5f4\ub78c" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "----\n", "### gist\ub97c \uc774\uc6a9\ud55c \ubc29\ubc95" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \ud398\uc774\uc2a4\ubd81 PythonKorea\uac15\ub0a8\uc2a4\ud130\ub514 \uae40\uc815\uc8fc\ub2d8 \uc81c\uacf5\n", "\n", " \uc5b4\uc81c \ubc1c\ud45c\uc790\ub8cc\uc785\ub2c8\ub2e4. \uad50\uc7ac\uc640 \ub3d9\uc77c\ud55c \ub0b4\uc6a9\uc785\ub2c8\ub2e4\ub9cc \ucc38\uace0\ub85c \uc62c\ub824\ubd05\ub2c8\ub2e4.\n", " http://nbviewer.ipython.org/gist/haje01/44825afdb0b54ac39150\n", " \uc5ec\ucb64\ubcf4\uc168\ub358 IPython Notebook\uc744 gist\ub97c \ud1b5\ud574 nbviewer\uc5d0 \uc62c\ub9ac\ub294 \uacfc\uc815\uc740 \ub2e4\uc74c\uacfc \uac19\uc774 \uac04\ub2e8\ud569\ub2c8\ub2e4:\n", " 1. \ub178\ud2b8\ubd81 \ud30c\uc77c(.ipynb) \ub0b4\uc6a9\uc744 \ubcf5\uc0ac\ud558\uace0 https://gist.github.com\ub85c \uac00\uc11c \ubd99\uc5ec \ub123\uc2b5\ub2c8\ub2e4.\n", " 2. \uc800\uc7a5\ud6c4 \uc0dd\uc131\ub41c URL\uc744 \ubcf5\uc0ac\ud558\uace0 http://nbviewer.ipython.org\ub85c \uac00\uc154\uc11c \ubd99\uc5ec \ub123\uc2b5\ub2c8\ub2e4.\n", "\n", " 3. \uc5ec\uae30\uc5d0\uc11c \uc0dd\uc131\ub41c URL\ub85c \uacf5\uc720\ud574 \uc8fc\uc2dc\uba74 \ub429\ub2c8\ub2e4.\n", " \ub2e4\ub9cc, \ubcc4\ub3c4 \ud30c\uc77c(\uc774\ubbf8\uc9c0 \ub4f1)\uc774 \uc788\ub294 \uacbd\uc6b0\uac00 \uc880 \ubb38\uc81c\uc778\ub370, \uc774\ub54c\ub294:\n", " 1. http://stackoverflow.com/questions/16425770/how-do-you-upload-images-to-a-gist \uc744 \ucc38\uace0\ud558\uc154\uc11c \uc774\ubbf8\uc9c0 \ud30c\uc77c\uc744 \uc62c\ub9bd\ub2c8\ub2e4.\n", " 2. \uc774\ub54c \uc774\ubbf8\uc9c0 \ud30c\uc77c\uc774 images/\ub77c\ub294 \ud3f4\ub354\uc5d0 \uc788\uc5c8\ub2e4\uba74, IPython\ub0b4 \ub178\ud2b8\ubd81\uc758 Markdown\uc140\uc5d0\uc11c \n", " ![desc](files/images/myimage.png)\n", " \ud615\uc2dd\uc73c\ub85c \uae30\uc220\ud558\uc154\uc57c \ud569\ub2c8\ub2e4.\n", " \n", "-----" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3.6 IPython\uc744 \uc0ac\uc6a9\ud55c \uc81c\ud488 \uac1c\ubc1c\uc744 \uc704\ud55c \ud301\n", "\n", "- \ud328\ub7ec\ub2e4\uc784 \uc2dc\ud504\ud2b8: \uac1c\ubc1c\uacfc \ub514\ubc84\uae45\uc774 \uc27d\uace0, \uad81\uadf9\uc801\uc73c\ub85c\ub294 \uc778\ud130\ub799\ud2f0\ube0c\ud558\uac8c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub3c4\ub85d \ucf54\ub4dc\ub97c \uc791\uc131\ud558\ub294 \uac83\n", "- \ucf54\ub529 \uc2a4\ud0c0\uc77c\uacfc \ub354\ubd88\uc5b4 \uc57d\uac04\uc758 \uc218\uc815\uc744 \ud544\uc694\ub85c \ud558\ub294 \ucf54\ub4dc \ub9ac\ub85c\ub529 \uac19\uc740 \uc808\ucc28\uc801\uc778 \uc138\ubd80\uc0ac\ud56d \uc874\uc7ac\n", "- \ub300\ubd80\ubd84\uc758 \uc0ac\uc6a9\uc790\ub294 \uc7ac\uc0ac\uc6a9\uc774 \uc27d\uace0 \uac00\ub2a5\ud55c \ud55c \ud070 \uc5b4\ub824\uc6c0 \uc5c6\uc774 \ud568\uc218\ub098 \ud504\ub85c\uadf8\ub7a8\uc758 \uc2e4\ud589 \uacb0\uacfc\ub97c \ud655\uc778\ud560 \uc218 \uc788\ub294 \ubc29\uc2dd\uc73c\ub85c \ucf54\ub4dc\ub97c \uad6c\uc870\ud654\ud558\uace0 \uc2f6\uc744 \uac83\uc774\ub2e4. \ub098\ub294 \ub3c5\ub9bd\uc801\uc73c\ub85c \uc2e4\ud589\ub418\ub294 \uba85\ub839\ud589 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\ub9cc\uc744 \uc704\ud55c \ucf54\ub4dc\ubcf4\ub2e4\ub294 IPython \uc5d0\uc11c \uc2e4\ud589\ub418\ub294 \uac83\uc744 \uc5fc\ub450\uc5d0 \ub450\uace0 \uac1c\ubc1c\ub41c \uc18c\ud504\ud2b8\uc6e8\uc5b4\uac00 \ud6e8\uc52c \ub354 \uc27d\uac8c \uc791\uc5c5\ud560 \uc218 \uc788\ub2e4.\n", "- \uc774\ub294 \uc5ec\ub7ec\ubd84\uc774 \uba87 \ub2ec, \uc2ec\uc9c0\uc5b4\ub294 **\uba87 \ub144 \uc804\uc5d0 \uc791\uc131\ud55c \ucf54\ub4dc\uc5d0\uc11c \ubc1c\uc0dd\ud55c \uc624\ub958\ub97c \ubd84\uc11d**\ud574\uc57c \ud560 \ub54c \ud2b9\ud788 \uc911\uc694\ud55c \ubb38\uc81c" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 3.6.1 \ubaa8\ub4c8 \uc758\uc874\uc131 \ub9ac\ub85c\ub529\ud558\uae30\n", "\n", "- import some_lib\uc744 \uc785\ub825\ud558\uba74 some_lib\uc5d0 \uc788\ub294 \ucf54\ub4dc\uac00 \uc2e4\ud589\n", "- \ubaa8\ub4e0 \ubcc0\uc218\uc640 \ud568\uc218, \uadf8 \uc548\uc5d0 import\ub294 \uc0c8\ub85c \uc0dd\uc131\ub41c some_lib \ubaa8\ub4c8\uc758 \ub124\uc784\uc2a4\ud398\uc774\uc2a4 \uc548\uc5d0 \uc800\uc7a5\n", "- \uadf8 \ud6c4\uc5d0 \ub2e4\uc2dc import some_lib\uc744 \uc785\ub825\ud558\uba74 \uc774\ubbf8 \uc874\uc7ac\ud558\ub294 \ubaa8\ub4c8 \ub124\uc784\uc2a4\ud398\uc774\uc2a4\uc5d0 \ub300\ud55c \ucc38\uc870\ub97c \uc5bb\uc744 \uc218 \uc788\ub2e4.\n", "- IPython\uc5d0\uc11c \ub300\ud654\ud615 \ucf54\ub4dc \uac1c\ubc1c\uc5d0 \uc788\uc5b4 \uc7a0\uc7ac\uc801\uc778 \uc5b4\ub824\uc6c0\uc740 \ubcc0\uacbd\ud55c \ub2e4\ub978 \ubaa8\ub4c8\uc5d0 \ub300\ud55c \uc758\uc874\uc131\uc744 \uac00\uc9c0\ub294 \uc2a4\ud06c\ub9bd\ud2b8\ub97c %run \uc73c\ub85c \uc2e4\ud589\ud588\uc744 \ub54c \uacaa\uac8c \ub420 \uac83" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " import some_lib\n", "\n", " x = 5\n", " y = [1,2,3,4]\n", " result = some_lib.get_answer(x, y)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- %run test_script.py\uc744 \uc2e4\ud589\ud558\uace0 some_lib.py \ud30c\uc77c\uc744 \ubcc0\uacbd\ud55c \ub2e4\uc74c \ub2e4\uc2dc %run test_script.py\ub97c \uc2e4\ud589\ud558\uba74 \ubcc0\uacbd\ub418\uae30 \uc804\uc758 some_lib\uc744 \ucc38\uc870\ud558\uac8c \ub418\ub294\ub370, \uc774\ub294 \ud30c\uc774\uc36c\uc774 \ubaa8\ub4c8\uc744 \ud55c \ubc88\ub9cc \ub85c\ub529\ud558\uae30 \ub54c\ubb38\n", "- \uc774\ub7f0 \ud615\ud0dc\ub294 \uc790\ub3d9\uc801\uc73c\ub85c \ucf54\ub4dc \ubcc0\uacbd\uc744 \uc804\ud30c\ud574\uc8fc\ub294 MATALB \uac19\uc740 \ub2e4\ub978 \ub370\uc774\ud130 \ubd84\uc11d \ud658\uacbd\uacfc\ub294 \ub2e4\ub974\ub2e4.\n", "- \uc774\ub7f0 \ubb38\uc81c\uc5d0 \ub300\uc751\ud558\uae30 \uc704\ud55c \uba87 \uac00\uc9c0 \uc635\uc158\n", "- \uccab\ubc88\uc9f8 \ubc29\ubc95\uc740 \ud30c\uc774\uc36c\uc758 \ub0b4\uc7a5 reload \ud568\uc218\ub97c \uc774\uc6a9\ud558\ub3c4\ub85d \ub2e4\uc74c \uc608\uc81c\ucc98\ub7fc test_script.py\ub97c \ubcc0\uacbd\ud558\ub294 \uac83\uc774\ub2e4.\n", "\n", "#### MATLAB\uc740 \uc790\ub3d9\uc801\uc73c\ub85c \ucf54\ub4dc \ubcc0\uacbd \uc804\ud30c\n", "\n", "- \ubaa8\ub4c8\uc774\ub098 \ud328\ud0a4\uc9c0\ub294 \ud55c \ud504\ub85c\uadf8\ub7a8 \uc548\uc5d0\uc11c\ub3c4 \ub2e4\uc591\ud55c \uacf3\uc5d0\uc11c import \ub420 \uc218 \uc788\uae30 \ub54c\ubb38\uc5d0 \ud30c\uc774\uc36c\uc740 \ubaa8\ub4c8\uc774 import \ub420 \ub54c\ub9c8\ub2e4 \ucf54\ub4dc\ub97c \uc2e4\ud589\ud558\uc9c0 \uc54a\uace0 \ucd5c\ucd08\uc5d0 \ubaa8\ub4c8\uc774 import \ub418\uc5c8\uc744 \ub54c \ubaa8\ub4c8\uc758 \ucf54\ub4dc\ub97c \uce90\uc2dc\uc5d0 \ub2f4\uc544\ub454\ub2e4. \uadf8\ub807\uc9c0 \uc54a\uc73c\uba74 \ubaa8\ub4c8 \ubc29\uc2dd\uacfc \ud6cc\ub96d\ud55c \ucf54\ub4dc \uad6c\uc131\uc774 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc758 \ud6a8\uc728\uc744 \ub5a8\uc5b4\ub728\ub9b4 \uc218 \uc788\ub2e4." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " import some_lib\n", " reload(some_lib)\n", "\n", " x = 5\n", " y = [1,2,3,4]\n", " result = some_lib.get_answer(x, y)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- \uc774\ub807\uac8c \ud558\uba74 test_script.py\ub97c \uc2e4\ud589\ud560 \ub54c\ub9c8\ub2e4 \ud56d\uc0c1 \uc0c8\ub86d\uac8c some_lib\uc758 \ubcf5\uc0ac\ubcf8\uc744 \uc5bb\uc744 \uc218 \uc788\ub2e4.\n", "- \ub2f9\uc5f0\ud788 \uc758\uc874\uc131\uc774 \uae4a\uc5b4\uc9c8\uc218\ub85d \ubaa8\ub4e0 \uacf3\uc5d0 reload\ub97c \uc0ac\uc6a9\ud558\ub3c4\ub85d \ucd94\uac00\ud574\uc57c \ud558\ub294 \ubc88\uac70\ub85c\uc6c0\uc774 \ub530\ub978\ub2e4.\n", "- \uc774\ub7f0 \ubb38\uc81c \ub54c\ubb38\uc5d0 IPython\uc5d0\uc11c\ub294 dreload(deep reload) \ud568\uc218 \uc874\uc7ac\n", "- dreload\ub294 \ub9e4\uc9c1 \ud568\uc218\ub294 \uc544\ub2c8\uba70 \uae4a\uc740(\uc7ac\uadc0\uc801\uc73c\ub85c) \ubaa8\ub4c8\uc744 \ub9ac\ub85c\ub529\ud558\uac8c \ud574\uc900\ub2e4.\n", "- \ub9cc\uc77c import some_lib \uc774\ub77c\uace0 \uc785\ub825\ud558\uc9c0 \uc54a\uace0 dreload(some_lib) \uc774\ub77c\uace0 \uc785\ub825\ud55c\ub2e4\uba74 some_lib\uacfc some_lib\uc5d0 \uc758\uc874\ud558\ub294 \ub2e4\ub978 \ubaa8\ub4e0 \ubaa8\ub4c8\uc744 \uc0c8\ub85c \uc77d\uc5b4\uc624\ub824\uace0 \ud560 \uac83\uc774\ub2e4.\n", "- \uc544\uc27d\uc9c0\ub9cc \ubaa8\ub4e0 \uacbd\uc6b0\uc5d0 \uc774 \ubc29\ubc95\uc744 \uc801\uc6a9\ud560 \uc218\ub294 \uc5c6\ub2e4.\n", "- \ud558\uc9c0\ub9cc IPython\uc744 \uc7ac\uc2dc\uc791\ud574\uc57c \ud558\ub294 \ubc88\uac70\ub85c\uc6c0\uc740 \ud574\uacb0\ud560 \uc218 \uc788\ub2e4." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 3.6.2 \ucf54\ub4dc \uc124\uacc4 \ud301\n", "\n", "- \ucf54\ub4dc \uc124\uacc4\uc5d0 \uc788\uc5b4 \uc9c0\ub984\uae38\uc740 \uc5c6\uc9c0\ub9cc \uc77c\uc744 \ud558\uba74\uc11c \ub3c4\uc6c0\uc774 \ub418\uc5c8\ub358 \uba87 \uac00\uc9c0 \uc0c1\uc704 \uc218\uc900\uc758 \uc6d0\ub9ac \uc18c\uac1c\n", "\n", "#### \uad00\ub828 \uc788\ub294 \uac1d\uccb4\uc640 \ub370\uc774\ud130\ub294 \uc720\uc9c0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " from my_functions import g\n", "\n", " def f(x, y):\n", " return g(x + y)\n", "\n", " def main():\n", " x = 6\n", " y = 7.5\n", " result = x + y\n", "\n", " if __name__ == '__main__':\n", " main()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### \uc774 \ud504\ub85c\uadf8\ub7a8\uc758 \ubb38\uc81c\uc810?\n", "\n", "- \ud504\ub85c\uadf8\ub7a8\uc758 \uc2e4\ud589\uc774 \ub05d\ub098\uba74 IPython \uc5d0\uc11c\ub294 main \ud568\uc218 \ub0b4\ubd80\uc5d0\uc11c \uc2e4\ud589\ub418\ub294 \ucf54\ub4dc\ub97c \ubaa8\ub4c8\uc758 \uae00\ub85c\ubc8c \ub124\uc784\uc2a4\ud398\uc774\uc2a4\uc5d0\uc11c \uc9c1\uc811 \uc2e4\ud589\ub418\ub3c4\ub85d \uace0\uce58\ub294 \uac83(\ud639\uc740 \ubaa8\ub4c8\uc774 import\uac00 \uac00\ub2a5\ud558\ub3c4\ub85d \ub9cc\ub4e4\uace0 \uc2f6\ub2e4\uba74 if \\_\\_name\\_\\_ == '\\_\\_main\\_\\_': \ube0c\ub85d \uc548\uc5d0\uc11c \uc2e4\ud589 \ub418\ub3c4\ub85d \ud55c\ub2e4)\n", "- \uc774\ub807\uac8c \ud558\uba74 %run\uc73c\ub85c \ud504\ub85c\uadf8\ub7a8\uc744 \uc2e4\ud589\uc2dc\ucf1c\ub3c4 main \ud568\uc218\uc5d0\uc11c \uc815\uc758\ub41c \ubaa8\ub4e0 \ubcc0\uc218\ub97c \uc0b4\ud3b4\ubcfc \uc218 \uc788\uac8c \ub41c\ub2e4.\n", "- \uc774 \uc608\uc81c\ub294 \ud070 \uc758\ubbf8\uac00 \uc5c6\uc5b4 \ubcf4\uc774\uc9c0\ub9cc \uc55e\uc73c\ub85c IPython\uc73c\ub85c \ub300\uc6a9\ub7c9 \ub370\uc774\ud130\ub97c \ub2e4\ub8e8\ub294 \uc880 \ub354 **\ubcf5\uc7a1\ud55c \ub370\uc774\ud130 \ubd84\uc11d \ubb38\uc81c**\ub97c \uc0b4\ud3b4\ubcfc \uac83\uc774\ubbc0\ub85c \uc774\ub807\uac8c \ud558\ub294 \ud3b8\uc774 \ub354 \ub0ab\ub2e4." ] }, { "cell_type": "code", "collapsed": false, "input": [ "%%writefile ch03/test_namespace.py\n", "def f(x, y):\n", " return g(x + y)\n", "\n", "def main():\n", " x = 6\n", " y = 7.5\n", " result = x + y\n", "\n", "if __name__ == '__main__':\n", " main()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Overwriting ch03/test_namespace.py\n" ] } ], "prompt_number": 87 }, { "cell_type": "code", "collapsed": false, "input": [ "%run ch03/test_namespace.py" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 88 }, { "cell_type": "code", "collapsed": false, "input": [ "x" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 89, "text": [ "'foobar'" ] } ], "prompt_number": 89 }, { "cell_type": "code", "collapsed": false, "input": [ "result" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 90, "text": [ "1.4666666666666666" ] } ], "prompt_number": 90 }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### __main__\uc5d0\uc11c \ud568\uc218 \uc2e4\ud589\n", "\n", "- main() \ud568\uc218\uc5d0 \uc788\ub358 \ub0b4\uc6a9\uc744 \\_\\_main\\_\\_ \uc73c\ub85c \uc62e\uae30\ub2c8 run\uc744 \uc2e4\ud589\ud55c \ud6c4\uc5d0 \ubcc0\uc218\ub4e4\uc744 \ucc38\uc870\ud560 \uc218 \uc788\uac8c \ub410\ub2e4." ] }, { "cell_type": "code", "collapsed": false, "input": [ "%%writefile ch03/test_namespace2.py\n", "def f(x, y):\n", " return g(x + y)\n", "\n", "if __name__ == '__main__':\n", " x = 6\n", " y = 7.5\n", " result = x + y" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Overwriting ch03/test_namespace2.py\n" ] } ], "prompt_number": 91 }, { "cell_type": "code", "collapsed": false, "input": [ "%run ch03/test_namespace2.py" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 92 }, { "cell_type": "code", "collapsed": false, "input": [ "x" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 93, "text": [ "6" ] } ], "prompt_number": 93 }, { "cell_type": "code", "collapsed": false, "input": [ "result" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 94, "text": [ "13.5" ] } ], "prompt_number": 94 }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### \uc911\ucca9\uc744 \ud53c\ud558\uc790\n", "\n", "- \ud568\uc218\ub97c \ud14c\uc2a4\ud2b8\ud558\uac70\ub098 \ub514\ubc84\uae45\ud560 \ub54c, \ud655\uc778\ud574\uc57c \ud560 \ucf54\ub4dc\ub97c \ubcf4\uae30 \uc704\ud574 \uba87 \uacb9\uc758 \uc591\ud30c \uaecd\uc9c8\uc744 \ubc97\uaca8\uc57c \ud560\uae4c? '\uc911\ucca9\uc744 \ud53c\ud558\uc790'\ub294 [Zen of Python(PEP20)](http://legacy.python.org/dev/peps/pep-0020/)\uc5d0 \ub098\uc624\ub294 \uad6c\uc808\uc778\ub370, \ub300\ud654\ud615 \ubc29\uc2dd\uc744 \uc704\ud55c \ucf54\ub4dc\ub97c \uac1c\ubc1c\ud560 \ub54c\ub3c4 \ub9c8\ucc2c\uac00\uc9c0\ub85c \uc801\uc6a9\n", "- \ud568\uc218\uc640 \ud074\ub798\uc2a4\ub97c \uc791\uc131\ud560 \ub54c \uac00\ub2a5\ud55c \ud55c \uacb0\ud569\ub3c4\ub97c \ub0ae\ucd94\uace0 \ubaa8\ub4c8\ud654\ud558\uba74 \ud14c\uc2a4\ud2b8(\ub2e8\uc704 \ud14c\uc2a4\ud2b8\ub97c \uc791\uc131\ud55c\ub2e4\uba74), \ub514\ubc84\uae45\uc774 \uc26c\uc6cc\uc9c8 \ubfd0 \uc544\ub2c8\ub77c \ub300\ud654\ud615 \ubc29\uc2dd\uc73c\ub85c \uc0ac\uc6a9\ud558\uae30\ub3c4 \uc26c\uc6cc\uc9c4\ub2e4.\n", "- [PEP 20(The Zen of Python) by example](http://artifex.org/~hblanks/talks/2011/pep20_by_example.html)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### \uae34 \ud30c\uc77c\uc5d0 \ub300\ud55c \ub450\ub824\uc6c0\uc744 \ubc84\ub9ac\uc790\n", "\n", "- IPython\uc5d0\uc11c 10\uac1c\uc758 \uc791\uace0 \uc11c\ub85c \uc5f0\uad00\ub41c \ud30c\uc77c(\uac01\uac01 100\uc5ec \uc904 \uc774\ud558\uc778)\uc744 \uc0ac\uc6a9\ud574\uc11c \uac1c\ubc1c\uc744 \uc9c4\ud589\ud55c\ub2e4\uba74 \ud55c\ub450 \uac1c\uc758 \uae34 \ud30c\uc77c\ub85c \uc791\uc5c5\ud560 \ub54c\ubcf4\ub2e4 \ub354 \uace8\uce58\uac00 \uc544\ud50c \uac83\n", "- \ud30c\uc77c \uac1c\uc218\uac00 \uc801\ub2e4\ub294 \ub9d0\uc740 \uace7 \ub9ac\ub85c\ub4dc\ud560 \ubaa8\ub4c8\uc774 \uc801\ub2e4\ub294 \uc758\ubbf8\uc774\uace0, \uc774 \ud30c\uc77c\uc77c \uc800 \ud30c\uc77c \ud3b8\uc9d1\ud558\ub294 \uc77c\uc774 \uc904\uc5b4\ub4e0\ub2e4.\n", "- \ub098\ub294 \ub0b4\ubd80\uc801\uc73c\ub85c \ub192\uc740 \uacb0\ud569\ub3c4\ub97c \uac00\uc9c0\ub294 \ud070 \ubaa8\ub4c8\uc744 \uc720\uc9c0\ud558\ub294 \uac83\uc774 \ud6e8\uc52c \uc720\uc6a9\ud558\uace0 '\ud30c\uc774\uc36c\uc2a4\ub7fd\ub2e4'\ub294 \uc0ac\uc2e4\uc744 \uae68\ub2ec\uc558\ub2e4.\n", "- \ud574\ubc95\uc744 \uc704\ud574 \ubc18\ubcf5\ud558\ub2e4\ubcf4\uba74 \uac00\ub054\uc740 \ud070 \ud30c\uc77c\uc744 \uc791\uc740 \ud30c\uc77c\ub85c \ucabc\uac1c\ub294 \uac83\uc774 \uc790\uc5f0\uc2a4\ub7fd\ub2e4\ub294 \uac83\uc744 \uc54c\uac8c \ub418\uae30\ub3c4 \ud55c\ub2e4.\n", "- \ubb3c\ub860 \uc774 \uc8fc\uc7a5\uc744 \uc9c0\ub098\uce58\uac8c \ubc1b\uc544\ub4e4\uc5ec\uc11c \uad34\ubb3c\ucc98\ub7fc \ud558\ub098\uc9dc\ub9ac \ud30c\uc77c\uc5d0 \ubaa8\ub4e0 \ucf54\ub4dc\ub97c \ub2e4 \uc9d1\uc5b4\ub123\uc73c\ub77c\ub294 \uac83\uc740 \uc544\ub2c8\ub2e4. \ud070 \ucf54\ub4dc \uae30\ubc18\uc5d0 \uc5b4\uc6b8\ub9ac\ub294 \ud569\ub9ac\uc801\uc774\uace0 \uc9c1\uad00\uc801\uc778 \ubaa8\ub4c8\uacfc \ud328\ud0a4\uc9c0 \uad6c\uc870\ub97c \ucc3e\ub294 \uc77c\uc740 \uc57d\uac04\uc758 \uc218\uace0\uac00 \ud544\uc694\ud558\uc9c0\ub9cc \uc81c\ub300\ub85c \uc77c\ud558\ub824\uba74 \ubb34\uc5c7\ubcf4\ub2e4 \uc911\uc694\ud55c \uacfc\uc815\n", "- \uac01\uac01\uc758 \ubaa8\ub4c8\uc740 \ub0b4\ubd80\uc801\uc73c\ub85c \uc751\uc9d1\ud574\uc57c \ud558\uace0 \uac01 \uae30\ub2a5\uc744 \uc704\ud55c \ud074\ub798\uc2a4\uc640 \ud568\uc218\ub97c \ucc3e\ub294 \uc77c\ub3c4 \ucd5c\ub300\ud55c \ubd84\uba85\ud574\uc57c \ud55c\ub2e4." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3.7 IPython \uace0\uae09 \uae30\ub2a5\n", "\n", "### 3.7.1 IPython \uce5c\ud654\uc801\uc778 \ud074\ub798\uc2a4 \ub9cc\ub4e4\uae30\n", "\n", "- IPython\uc740 \uc0b4\ud3b4\ubcf4\ub824\ub294 \ubaa8\ub4e0 \uac1d\uccb4\uc758 \ubb38\uc790\uc5f4 \ud45c\ud604\uc744 \ucf58\uc194 \uce5c\ud654\uc801\uc778 \ubaa8\uc591\uc73c\ub85c \ucd9c\ub825\n", "- \uc0ac\uc804, \ub9ac\uc2a4\ud2b8, \ud29c\ud50c \ub9ce\uc740 \uac1d\uccb4\uc5d0 \ub300\ud574 \ub0b4\uc7a5 pprint \ubaa8\ub4c8\uc744 \uc0ac\uc6a9\ud558\uba74 \uba4b\uc9c4 \ubaa8\uc591\uc73c\ub85c \ucd9c\ub825\n", "- \ud558\uc9c0\ub9cc \uc0ac\uc6a9\uc790 \uc815\uc758 \ud074\ub798\uc2a4\uc758 \uacbd\uc6b0\uc5d0\ub294 \uc9c1\uc811 \uc6d0\ud558\ub294 \ud615\uc2dd\uc758 \ubb38\uc790\uc5f4 \ucd9c\ub825\uc744 \uc0dd\uc131\ud574\uc918\uc57c\ub9cc \ud55c\ub2e4." ] }, { "cell_type": "code", "collapsed": false, "input": [ "class Message:\n", " def __init__(self, msg):\n", " self.msg = msg" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 95 }, { "cell_type": "code", "collapsed": false, "input": [ "x = Message('I have a secret')" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 96 }, { "cell_type": "code", "collapsed": false, "input": [ "# \ud074\ub798\uc2a4\uc758 \uae30\ubcf8 \ubb38\uc790\uc5f4 \ud45c\ud604\uc774 \uadf8\ub9ac \ubcf4\uae30 \uc88b\uc9c0 \uc54a\ub2e4.\n", "x" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 97, "text": [ "<__main__.Message instance at 0x10a272f80>" ] } ], "prompt_number": 97 }, { "cell_type": "markdown", "metadata": {}, "source": [ "- IPython\uc740 \\_\\_repr\\_\\_ \ub9e4\uc9c1 \uba54\uc11c\ub4dc\uc5d0\uc11c \ubc18\ud658\ub418\ub294 \ubb38\uc790\uc5f4\uc744 \ubc1b\uc544\uc11c(output = repr(obj)) \ucf58\uc194\ub85c \ucd9c\ub825\ud55c\ub2e4. \ub530\ub77c\uc11c \uc774 \ud074\ub798\uc2a4\uc5d0 \\_\\_repr\\_\\_ \uba54\uc11c\ub4dc\ub97c \ucd94\uac00\ud558\uc5ec \ucd9c\ub825\uc744 \uc880 \ub354 \ubcf4\uae30 \uc88b\uac8c \ud574\ubcf4\uc790." ] }, { "cell_type": "code", "collapsed": false, "input": [ "class Message:\n", " def __init__(self, msg):\n", " self.msg = msg\n", " def __repr__(self):\n", " return 'Message %s' % self.msg" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 98 }, { "cell_type": "code", "collapsed": false, "input": [ "x = Message('I have a secret')" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 99 }, { "cell_type": "code", "collapsed": false, "input": [ "x" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 100, "text": [ "Message I have a secret" ] } ], "prompt_number": 100 }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 3.7.2 \ud504\ub85c\ud30c\uc77c\uacfc \uc124\uc815\n", "\n", "- \uc0c9\uc0c1, \ud504\ub86c\ud504\ud2b8, \uc904 \uac04\uaca9 \ub4f1 \uc678\ud615\uacfc IPython \uc258\uc758 \ub3d9\uc791\uc5d0 \uad00\ud55c \ub300\ubd80\ubd84\uc758 \ud56d\ubaa9\uc740 \ud3ed\ub113\uc740 \uc124\uc815 \uc2dc\uc2a4\ud15c\uc744 \ud1b5\ud574 \ubcc0\uacbd \uac00\ub2a5\n", "- \uc0c9\uc0c1 \uc2a4\ud0a4\ub9c8 \ubcc0\uacbd\n", "- \uc785\u2219\ucd9c\ub825 \ud504\ub86c\ud504\ud2b8 \ubaa8\uc591 \ubcc0\uacbd, Out \ud504\ub86c\ud504\ud2b8\uc640 \uadf8 \ub2e4\uc74c In \ud504\ub86c\ud504\ud2b8 \uc0ac\uc774\uc758 \ube48 \uc904 \uc81c\uac70\n", "- \uc5ec\ub7ec \uac1c\uc758 \uc784\uc758\uc758 \ud30c\uc774\uc36c \ubb38\uc7a5 \uc2e4\ud589. \uc774 \uc124\uc815\uc744 \ud1b5\ud574 \ud56d\uc0c1 \uc0ac\uc6a9\ud558\ub294 \ubaa8\ub4c8\uc744 import \ud558\uac70\ub098 IPython\uc744 \uc2e4\ud589\ud560 \ub54c\ub9c8\ub2e4 \uc2e4\ud589\ub418\uae30\ub97c \uc6d0\ud558\ub294 \ucf54\ub4dc \ucd94\uac00\uac00 \uac00\ub2a5\n", "- line_profiler\uc758 \ub9e4\uc9c1 \ud568\uc218\uc778 %lprun \uac19\uc740 IPython \ud655\uc7a5 \ud65c\uc131\ud654\n", "- \uc0ac\uc6a9\uc790 \ub9e4\uc9c1 \ud568\uc218 \uc815\uc758, \uc2dc\uc2a4\ud15c \ubcc4\uce6d \uc815\uc758\n", "- UNIX: ~/.config/ipython/\n", "- Windows: %HOME%/.ipython/\n", "- \ub514\ub809\ud1a0\ub9ac\uc5d0 \uc788\ub294 ipython_config.py \ud30c\uc77c\uc5d0 \uc9c0\uc815\n", "- \uc0ac\uc6a9\uc790 \ud648 \ub514\ub809\ud1a0\ub9ac\ub294 \uc2dc\uc2a4\ud15c\uc5d0 \ub530\ub77c \ub2e4\ub974\ub2e4.\n", "- \uc124\uc815\uc740 \ud2b9\uc815 \ud504\ub85c\ud30c\uc77c\uc5d0 \uae30\ubc18\ud574\uc11c \uc218\ud589\n", "- \uc77c\ubc18\uc801\uc73c\ub85c IPython\uc744 \uc2e4\ud589\ud558\uba74 \uae30\ubcf8\uc801\uc73c\ub85c profiler_defualt \ub514\ub809\ud1a0\ub9ac\uc5d0 \uc800\uc7a5\ub41c default \ud504\ub85c\ud30c\uc77c\uc744 \ubd88\ub7ec\uc628\ub2e4. \n", "- \ub2e4\ud589\uc2a4\ub7fd\uac8c\ub3c4 \uac01 \uc124\uc815 \ud56d\ubaa9\ub9c8\ub2e4 \uc5b4\ub5a4 \ub0b4\uc6a9\uc778\uc9c0 \uc124\uba85\ud574\uc8fc\ub294 \uc8fc\uc11d\uc774 \ub2ec\ub824\uc788\uae30 \ub54c\ubb38\uc5d0 \ub3c5\uc790\uac00 \uc9c1\uc811 \uace0\uccd0\ubcf4\ub3c4\ub85d \uc219\uc81c\ub85c \ub0a8\uaca8\ub450\uaca0\ub2e4." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Mac \uc0ac\uc6a9\uc790 \ud504\ub85c\ud30c\uc77c \ud30c\uc77c \uc704\uce58\n", "\n", "- /Users/re4lfl0w/.ipython/profile_default/ipython_config.py\n", "- ipython\ub9cc \uc124\uce58\ud55c \ud6c4\uc5d0\ub294 \uc774 **\uc0ac\uc6a9\uc790 \ud504\ub85c\ud30c\uc77c\uc774 \uc808\ub300 \ubcf4\uc774\uc9c0 \uc54a\ub294\ub2e4**. ipython profile create secret_project \ucc98\ub7fc \ud504\ub85c\ud30c\uc77c\uc744 \ud558\ub098 \ub9cc\ub4e4\uc5b4\uc918\uc57c \uc774 \ud3f4\ub354\uac00 \uc0dd\uc131\uc774 \ub41c\ub2e4. \ucc45\uc758 \uc21c\uc11c\uac00 \uc57d\uac04 \uc798\ubabb\ub418\uc5b4\uc11c \uc5c4\uccad\ub09c \uc0bd\uc9c8 \ud6c4\uc5d0 \uc54c\uc544\ub0c8\ub2e4." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " # Configuration file for ipython.\n", "\n", " c = get_config()\n", "\n", " #------------------------------------------------------------------------------\n", " # InteractiveShellApp configuration\n", " #------------------------------------------------------------------------------\n", "\n", " # A Mixin for applications that start InteractiveShell instances.\n", " # \n", " # Provides configurables for loading extensions and executing files as part of\n", " # configuring a Shell environment.\n", " # \n", " # The following methods should be called by the :meth:`initialize` method of the\n", " # subclass:\n", " # \n", " # - :meth:`init_path`\n", " # - :meth:`init_shell` (to be implemented by the subclass)\n", " # - :meth:`init_gui_pylab`\n", " # - :meth:`init_extensions`\n", " # - :meth:`init_code`\n", "\n", " # Execute the given command string.\n", " # c.InteractiveShellApp.code_to_run = ''\n", "\n", " # lines of code to run at IPython startup.\n", " # c.InteractiveShellApp.exec_lines = []\n", "\n", " # Enable GUI event loop integration with any of ('glut', 'gtk', 'gtk3', 'none',\n", " # 'osx', 'pyglet', 'qt', 'qt4', 'tk', 'wx').\n", " # c.InteractiveShellApp.gui = None\n", "\n", " # Pre-load matplotlib and numpy for interactive use, selecting a particular\n", " # matplotlib backend and loop integration.\n", " # c.InteractiveShellApp.pylab = None\n", "\n", " # Configure matplotlib for interactive use with the default matplotlib backend.\n", " # c.InteractiveShellApp.matplotlib = None\n", "\n", " # If true, IPython will populate the user namespace with numpy, pylab, etc. and\n", " # an 'import *' is done from numpy and pylab, when using pylab mode.\n", " # \n", " # When False, pylab mode should not import any names into the user namespace.\n", " # c.InteractiveShellApp.pylab_import_all = True\n", "\n", " # A list of dotted module names of IPython extensions to load.\n", " # c.InteractiveShellApp.extensions = []\n", "\n", " # Run the module as a script.\n", " # c.InteractiveShellApp.module_to_run = ''\n", "\n", " # dotted module name of an IPython extension to load.\n", " # c.InteractiveShellApp.extra_extension = ''\n", "\n", " # List of files to run at IPython startup.\n", " # c.InteractiveShellApp.exec_files = []\n", "\n", " # A file to be run\n", " # c.InteractiveShellApp.file_to_run = ''\n", "\n", " #------------------------------------------------------------------------------\n", " # TerminalIPythonApp configuration\n", " #------------------------------------------------------------------------------\n", "\n", " # TerminalIPythonApp will inherit config from: BaseIPythonApplication,\n", " # Application, InteractiveShellApp\n", "\n", " # Pre-load matplotlib and numpy for interactive use, selecting a particular\n", " # matplotlib backend and loop integration.\n", " # c.TerminalIPythonApp.pylab = None\n", "\n", " # Create a massive crash report when IPython encounters what may be an internal\n", " # error. The default is to append a short message to the usual traceback\n", " # c.TerminalIPythonApp.verbose_crash = False\n", "\n", " # Run the module as a script.\n", " # c.TerminalIPythonApp.module_to_run = ''\n", "\n", " # The date format used by logging formatters for %(asctime)s\n", " # c.TerminalIPythonApp.log_datefmt = '%Y-%m-%d %H:%M:%S'\n", "\n", " # Whether to overwrite existing config files when copying\n", " # c.TerminalIPythonApp.overwrite = False\n", "\n", " # Execute the given command string.\n", " # c.TerminalIPythonApp.code_to_run = ''\n", "\n", " # Set the log level by value or name.\n", " # c.TerminalIPythonApp.log_level = 30\n", "\n", " # lines of code to run at IPython startup.\n", " # c.TerminalIPythonApp.exec_lines = []\n", "\n", " # Suppress warning messages about legacy config files\n", " # c.TerminalIPythonApp.ignore_old_config = False\n", "\n", " # Path to an extra config file to load.\n", " # \n", " # If specified, load this config file in addition to any other IPython config.\n", " # c.TerminalIPythonApp.extra_config_file = u''\n", "\n", " # dotted module name of an IPython extension to load.\n", " # c.TerminalIPythonApp.extra_extension = ''\n", "\n", " # A file to be run\n", " # c.TerminalIPythonApp.file_to_run = ''\n", "\n", " # The IPython profile to use.\n", " # c.TerminalIPythonApp.profile = u'default'\n", "\n", " # Configure matplotlib for interactive use with the default matplotlib backend.\n", " # c.TerminalIPythonApp.matplotlib = None\n", "\n", " # If a command or file is given via the command-line, e.g. 'ipython foo.py\n", " # c.TerminalIPythonApp.force_interact = False\n", "\n", " # If true, IPython will populate the user namespace with numpy, pylab, etc. and\n", " # an 'import *' is done from numpy and pylab, when using pylab mode.\n", " # \n", " # When False, pylab mode should not import any names into the user namespace.\n", " # c.TerminalIPythonApp.pylab_import_all = True\n", "\n", " # The name of the IPython directory. This directory is used for logging\n", " # configuration (through profiles), history storage, etc. The default is usually\n", " # $HOME/.ipython. This options can also be specified through the environment\n", " # variable IPYTHONDIR.\n", " # c.TerminalIPythonApp.ipython_dir = u'/Users/re4lfl0w/.ipython'\n", "\n", " # Whether to display a banner upon starting IPython.\n", " # c.TerminalIPythonApp.display_banner = True\n", "\n", " # Whether to install the default config files into the profile dir. If a new\n", " # profile is being created, and IPython contains config files for that profile,\n", " # then they will be staged into the new directory. Otherwise, default config\n", " # files will be automatically generated.\n", " # c.TerminalIPythonApp.copy_config_files = False\n", "\n", " # List of files to run at IPython startup.\n", " # c.TerminalIPythonApp.exec_files = []\n", "\n", " # Enable GUI event loop integration with any of ('glut', 'gtk', 'gtk3', 'none',\n", " # 'osx', 'pyglet', 'qt', 'qt4', 'tk', 'wx').\n", " # c.TerminalIPythonApp.gui = None\n", "\n", " # A list of dotted module names of IPython extensions to load.\n", " # c.TerminalIPythonApp.extensions = []\n", "\n", " # Start IPython quickly by skipping the loading of config files.\n", " # c.TerminalIPythonApp.quick = False\n", "\n", " # The Logging format template\n", " # c.TerminalIPythonApp.log_format = '[%(name)s]%(highlevel)s %(message)s'\n", "\n", " #------------------------------------------------------------------------------\n", " # TerminalInteractiveShell configuration\n", " #------------------------------------------------------------------------------\n", "\n", " # TerminalInteractiveShell will inherit config from: InteractiveShell\n", "\n", " # auto editing of files with syntax errors.\n", " # c.TerminalInteractiveShell.autoedit_syntax = False\n", "\n", " # Use colors for displaying information about objects. Because this information\n", " # is passed through a pager (like 'less'), and some pagers get confused with\n", " # color codes, this capability can be turned off.\n", " # c.TerminalInteractiveShell.color_info = True\n", "\n", " # A list of ast.NodeTransformer subclass instances, which will be applied to\n", " # user input before code is run.\n", " # c.TerminalInteractiveShell.ast_transformers = []\n", "\n", " # \n", " # c.TerminalInteractiveShell.history_length = 10000\n", "\n", " # Don't call post-execute functions that have failed in the past.\n", " # c.TerminalInteractiveShell.disable_failing_post_execute = False\n", "\n", " # Show rewritten input, e.g. for autocall.\n", " # c.TerminalInteractiveShell.show_rewritten_input = True\n", "\n", " # Set the color scheme (NoColor, Linux, or LightBG).\n", " # c.TerminalInteractiveShell.colors = 'LightBG'\n", "\n", " # Autoindent IPython code entered interactively.\n", " # c.TerminalInteractiveShell.autoindent = True\n", "\n", " # \n", " # c.TerminalInteractiveShell.separate_in = '\\n'\n", "\n", " # Deprecated, use PromptManager.in2_template\n", " # c.TerminalInteractiveShell.prompt_in2 = ' .\\\\D.: '\n", "\n", " # \n", " # c.TerminalInteractiveShell.separate_out = ''\n", "\n", " # Deprecated, use PromptManager.in_template\n", " # c.TerminalInteractiveShell.prompt_in1 = 'In [\\\\#]: '\n", "\n", " # Make IPython automatically call any callable object even if you didn't type\n", " # explicit parentheses. For example, 'str 43' becomes 'str(43)' automatically.\n", " # The value can be '0' to disable the feature, '1' for 'smart' autocall, where\n", " # it is not applied if there are no more arguments on the line, and '2' for\n", " # 'full' autocall, where all callable objects are automatically called (even if\n", " # no arguments are present).\n", " # c.TerminalInteractiveShell.autocall = 0\n", "\n", " # Number of lines of your screen, used to control printing of very long strings.\n", " # Strings longer than this number of lines will be sent through a pager instead\n", " # of directly printed. The default value for this is 0, which means IPython\n", " # will auto-detect your screen size every time it needs to print certain\n", " # potentially long strings (this doesn't change the behavior of the 'print'\n", " # keyword, it's only triggered internally). If for some reason this isn't\n", " # working well (it needs curses support), specify it yourself. Otherwise don't\n", " # change the default.\n", " # c.TerminalInteractiveShell.screen_length = 0\n", "\n", " # Set the editor used by IPython (default to $EDITOR/vi/notepad).\n", " # c.TerminalInteractiveShell.editor = 'vi'\n", "\n", " # Deprecated, use PromptManager.justify\n", " # c.TerminalInteractiveShell.prompts_pad_left = True\n", "\n", " # The part of the banner to be printed before the profile\n", " # c.TerminalInteractiveShell.banner1 = 'Python 2.7.2 (default, Oct 11 2012, 20:14:37) \\nType \"copyright\", \"credits\" or \"license\" for more information.\\n\\nIPython 1.1.0 -- An enhanced Interactive Python.\\n? -> Introduction and overview of IPython\\'s features.\\n%quickref -> Quick reference.\\nhelp -> Python\\'s own help system.\\nobject? -> Details about \\'object\\', use \\'object??\\' for extra details.\\n'\n", "\n", " # \n", " # c.TerminalInteractiveShell.readline_parse_and_bind = ['tab: complete', '\"\\\\C-l\": clear-screen', 'set show-all-if-ambiguous on', '\"\\\\C-o\": tab-insert', '\"\\\\C-r\": reverse-search-history', '\"\\\\C-s\": forward-search-history', '\"\\\\C-p\": history-search-backward', '\"\\\\C-n\": history-search-forward', '\"\\\\e[A\": history-search-backward', '\"\\\\e[B\": history-search-forward', '\"\\\\C-k\": kill-line', '\"\\\\C-u\": unix-line-discard']\n", "\n", " # The part of the banner to be printed after the profile\n", " # c.TerminalInteractiveShell.banner2 = ''\n", "\n", " # \n", " # c.TerminalInteractiveShell.separate_out2 = ''\n", "\n", " # \n", " # c.TerminalInteractiveShell.wildcards_case_sensitive = True\n", "\n", " # \n", " # c.TerminalInteractiveShell.debug = False\n", "\n", " # Set to confirm when you try to exit IPython with an EOF (Control-D in Unix,\n", " # Control-Z/Enter in Windows). By typing 'exit' or 'quit', you can force a\n", " # direct exit without any confirmation.\n", " # c.TerminalInteractiveShell.confirm_exit = True\n", "\n", " # \n", " # c.TerminalInteractiveShell.ipython_dir = ''\n", "\n", " # \n", " # c.TerminalInteractiveShell.readline_remove_delims = '-/~'\n", "\n", " # Start logging to the default log file.\n", " # c.TerminalInteractiveShell.logstart = False\n", "\n", " # The name of the logfile to use.\n", " # c.TerminalInteractiveShell.logfile = ''\n", "\n", " # The shell program to be used for paging.\n", " # c.TerminalInteractiveShell.pager = 'less'\n", "\n", " # Enable magic commands to be called without the leading %.\n", " # c.TerminalInteractiveShell.automagic = True\n", "\n", " # Save multi-line entries as one entry in readline history\n", " # c.TerminalInteractiveShell.multiline_history = True\n", "\n", " # \n", " # c.TerminalInteractiveShell.readline_use = True\n", "\n", " # Enable deep (recursive) reloading by default. IPython can use the deep_reload\n", " # module which reloads changes in modules recursively (it replaces the reload()\n", " # function, so you don't need to change anything to use it). deep_reload()\n", " # forces a full reload of modules whose code may have changed, which the default\n", " # reload() function does not. When deep_reload is off, IPython will use the\n", " # normal reload(), but deep_reload will still be available as dreload().\n", " # c.TerminalInteractiveShell.deep_reload = False\n", "\n", " # Start logging to the given file in append mode.\n", " # c.TerminalInteractiveShell.logappend = ''\n", "\n", " # \n", " # c.TerminalInteractiveShell.xmode = 'Context'\n", "\n", " # \n", " # c.TerminalInteractiveShell.quiet = False\n", "\n", " # Enable auto setting the terminal title.\n", " # c.TerminalInteractiveShell.term_title = False\n", "\n", " # \n", " # c.TerminalInteractiveShell.object_info_string_level = 0\n", "\n", " # Deprecated, use PromptManager.out_template\n", " # c.TerminalInteractiveShell.prompt_out = 'Out[\\\\#]: '\n", "\n", " # Set the size of the output cache. The default is 1000, you can change it\n", " # permanently in your config file. Setting it to 0 completely disables the\n", " # caching system, and the minimum value accepted is 20 (if you provide a value\n", " # less than 20, it is reset to 0 and a warning is issued). This limit is\n", " # defined because otherwise you'll spend more time re-flushing a too small cache\n", " # than working\n", " # c.TerminalInteractiveShell.cache_size = 1000\n", "\n", " # 'all', 'last', 'last_expr' or 'none', specifying which nodes should be run\n", " # interactively (displaying output from expressions).\n", " # c.TerminalInteractiveShell.ast_node_interactivity = 'last_expr'\n", "\n", " # Automatically call the pdb debugger after every exception.\n", " # c.TerminalInteractiveShell.pdb = False\n", "\n", " #------------------------------------------------------------------------------\n", " # PromptManager configuration\n", " #------------------------------------------------------------------------------\n", "\n", " # This is the primary interface for producing IPython's prompts.\n", "\n", " # Output prompt. '\\#' will be transformed to the prompt number\n", " # c.PromptManager.out_template = 'Out[\\\\#]: '\n", "\n", " # Continuation prompt.\n", " # c.PromptManager.in2_template = ' .\\\\D.: '\n", "\n", " # If True (default), each prompt will be right-aligned with the preceding one.\n", " # c.PromptManager.justify = True\n", "\n", " # Input prompt. '\\#' will be transformed to the prompt number\n", " # c.PromptManager.in_template = 'In [\\\\#]: '\n", "\n", " # \n", " # c.PromptManager.color_scheme = 'Linux'\n", "\n", " #------------------------------------------------------------------------------\n", " # HistoryManager configuration\n", " #------------------------------------------------------------------------------\n", "\n", " # A class to organize all history-related functionality in one place.\n", "\n", " # HistoryManager will inherit config from: HistoryAccessor\n", "\n", " # \n", " # c.HistoryManager.db_log_output = False\n", "\n", " # \n", " # c.HistoryManager.db_cache_size = 0\n", "\n", " # Path to file to use for SQLite history database.\n", " # \n", " # By default, IPython will put the history database in the IPython profile\n", " # directory. If you would rather share one history among profiles, you can set\n", " # this value in each, so that they are consistent.\n", " # \n", " # Due to an issue with fcntl, SQLite is known to misbehave on some NFS mounts.\n", " # If you see IPython hanging, try setting this to something on a local disk,\n", " # e.g::\n", " # \n", " # ipython --HistoryManager.hist_file=/tmp/ipython_hist.sqlite\n", " # c.HistoryManager.hist_file = u''\n", "\n", " # Options for configuring the SQLite connection\n", " # \n", " # These options are passed as keyword args to sqlite3.connect when establishing\n", " # database conenctions.\n", " # c.HistoryManager.connection_options = {}\n", "\n", " # enable the SQLite history\n", " # \n", " # set enabled=False to disable the SQLite history, in which case there will be\n", " # no stored history, no SQLite connection, and no background saving thread.\n", " # This may be necessary in some threaded environments where IPython is embedded.\n", " # c.HistoryManager.enabled = True\n", "\n", " #------------------------------------------------------------------------------\n", " # ProfileDir configuration\n", " #------------------------------------------------------------------------------\n", "\n", " # An object to manage the profile directory and its resources.\n", " # \n", " # The profile directory is used by all IPython applications, to manage\n", " # configuration, logging and security.\n", " # \n", " # This object knows how to find, create and manage these directories. This\n", " # should be used by any code that wants to handle profiles.\n", "\n", " # Set the profile location directly. This overrides the logic used by the\n", " # `profile` option.\n", " # c.ProfileDir.location = u''\n", "\n", " #------------------------------------------------------------------------------\n", " # PlainTextFormatter configuration\n", " #------------------------------------------------------------------------------\n", "\n", " # The default pretty-printer.\n", " # \n", " # This uses :mod:`IPython.lib.pretty` to compute the format data of the object.\n", " # If the object cannot be pretty printed, :func:`repr` is used. See the\n", " # documentation of :mod:`IPython.lib.pretty` for details on how to write pretty\n", " # printers. Here is a simple example::\n", " # \n", " # def dtype_pprinter(obj, p, cycle):\n", " # if cycle:\n", " # return p.text('dtype(...)')\n", " # if hasattr(obj, 'fields'):\n", " # if obj.fields is None:\n", " # p.text(repr(obj))\n", " # else:\n", " # p.begin_group(7, 'dtype([')\n", " # for i, field in enumerate(obj.descr):\n", " # if i > 0:\n", " # p.text(',')\n", " # p.breakable()\n", " # p.pretty(field)\n", " # p.end_group(7, '])')\n", "\n", " # PlainTextFormatter will inherit config from: BaseFormatter\n", "\n", " # \n", " # c.PlainTextFormatter.type_printers = {}\n", "\n", " # \n", " # c.PlainTextFormatter.newline = '\\n'\n", "\n", " # \n", " # c.PlainTextFormatter.float_precision = ''\n", "\n", " # \n", " # c.PlainTextFormatter.verbose = False\n", "\n", " # \n", " # c.PlainTextFormatter.deferred_printers = {}\n", "\n", " # \n", " # c.PlainTextFormatter.pprint = True\n", "\n", " # \n", " # c.PlainTextFormatter.max_width = 79\n", "\n", " # \n", " # c.PlainTextFormatter.singleton_printers = {}\n", "\n", " #------------------------------------------------------------------------------\n", " # IPCompleter configuration\n", " #------------------------------------------------------------------------------\n", "\n", " # Extension of the completer class with IPython-specific features\n", "\n", " # IPCompleter will inherit config from: Completer\n", "\n", " # Instruct the completer to omit private method names\n", " # \n", " # Specifically, when completing on ``object. ``.\n", " # \n", " # When 2 [default]: all names that start with '_' will be excluded.\n", " # \n", " # When 1: all 'magic' names (``__foo__``) will be excluded.\n", " # \n", " # When 0: nothing will be excluded.\n", " # c.IPCompleter.omit__names = 2\n", "\n", " # Whether to merge completion results into a single list\n", " # \n", " # If False, only the completion results from the first non-empty completer will\n", " # be returned.\n", " # c.IPCompleter.merge_completions = True\n", "\n", " # Instruct the completer to use __all__ for the completion\n", " # \n", " # Specifically, when completing on ``object. ``.\n", " # \n", " # When True: only those names in obj.__all__ will be included.\n", " # \n", " # When False [default]: the __all__ attribute is ignored\n", " # c.IPCompleter.limit_to__all__ = False\n", "\n", " # Activate greedy completion\n", " # \n", " # This will enable completion on elements of lists, results of function calls,\n", " # etc., but can be unsafe because the code is actually evaluated on TAB.\n", " # c.IPCompleter.greedy = False\n", "\n", " #------------------------------------------------------------------------------\n", " # ScriptMagics configuration\n", " #------------------------------------------------------------------------------\n", "\n", " # Magics for talking to scripts\n", " # \n", " # This defines a base `%%script` cell magic for running a cell with a program in\n", " # a subprocess, and registers a few top-level magics that call %%script with\n", " # common interpreters.\n", "\n", " # Extra script cell magics to define\n", " # \n", " # This generates simple wrappers of `%%script foo` as `%%foo`.\n", " # \n", " # If you want to add script magics that aren't on your path, specify them in\n", " # script_paths\n", " # c.ScriptMagics.script_magics = []\n", "\n", " # Dict mapping short 'ruby' names to full paths, such as '/opt/secret/bin/ruby'\n", " # \n", " # Only necessary for items in script_magics where the default path will not find\n", " # the right interpreter.\n", " # c.ScriptMagics.script_paths = {}\n", "\n", " #------------------------------------------------------------------------------\n", " # StoreMagics configuration\n", " #------------------------------------------------------------------------------\n", "\n", " # Lightweight persistence for python variables.\n", " # \n", " # Provides the %store magic.\n", "\n", " # If True, any %store-d variables will be automatically restored when IPython\n", " # starts.\n", " # c.StoreMagics.autorestore = False\n", "\n", " #c.TerminalIPythonApp.extensions = [\n", " # 'line_profiler'\n", " # ]\n", "\n", " #c.TerminalIPythonApp.extensions = ['line_profiler']\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### IPython \uc0c8\ub85c\uc6b4 \ud504\ub85c\ud30c\uc77c \uc0dd\uc131" ] }, { "cell_type": "code", "collapsed": false, "input": [ "!ipython profile create secret_project" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 101 }, { "cell_type": "markdown", "metadata": {}, "source": [ " [ProfileCreate] Generating default config file: u'/Users/re4lfl0w/.ipython/profile_secret_project/ipython_config.py'\n", " [ProfileCreate] Generating default config file: u'/Users/re4lfl0w/.ipython/profile_secret_project/ipython_notebook_config.py'\n", " [ProfileCreate] Generating default config file: u'/Users/re4lfl0w/.ipython/profile_secret_project/ipython_nbconvert_config.py'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " $ ipython --profile=secret_project\n", " Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45) \n", " Type \"copyright\", \"credits\" or \"license\" for more information.\n", "\n", " IPython 1.2.1 -- An enhanced Interactive Python.\n", " ? -> Introduction and overview of IPython's features.\n", " %quickref -> Quick reference.\n", " help -> Python's own help system.\n", " object? -> Details about 'object', use 'object??' for extra details.\n", "\n", " IPython profile: secret_project" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- [Introduction to IPython configuration](http://ipython.org/ipython-doc/dev/config/intro.html#profiles)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3.8 \uac10\uc0ac\uc758 \uae00\n", "\n", "- IPython \uac1c\ubc1c\ud300\uc774 \uc791\uc131\ud55c \ud6cc\ub96d\ud55c \ubb38\uc11c\uc5d0\uc11c \ub9ce\uc740 \ubd80\ubd84 \uc778\uc6a9" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## IPython \ucc38\uace0 \uc790\ub8cc\n", "\n", "- [PyConZA2013 presentation](http://nbviewer.ipython.org/github/Tooblippe/zapycon2013_ipython_science/blob/master/src/pycon13_ipython.ipynb)\n", "- [IPython Notebook \uacf5\uc2dd \ubb38\uc11c](http://ipython.org/ipython-doc/dev/notebook/index.html)\n", "- [\ud30c\uc774\uc36c(Python) \uac1c\ubc1c\uc790\uc758 \ud14c\ud06c\ub2c8\uceec \uc774\uc288(\uc774\uac15\uc131 \uad50\uc218)](http://www.youtube.com/watch?v=mJ2msJ5d5Ec): IPython \uc18c\uac1c, \ub370\ucf54\ub808\uc774\ud130, \uba54\ud0c0 \ud504\ub85c\uadf8\ub798\ubc0d \ub4f1 \uc911\u2219\uace0\uae09 \uae30\ubc95 \uc18c\uac1c\n", "- [\ubcf4\uc548\uc744 \uc704\ud55c \uac15\ub825\ud55c \ud30c\uc774\uc36c(Python) \uc2a4\ud06c\ub9bd\ud2b8 \uc5b8\uc5b4(\ucd5c\uc6d0\ud601 \uc774\uc0ac)](http://www.youtube.com/watch?v=galZ5TIQANc): \uc774\uac74 \ubcf4\uc548\ucabd \uc774\uc57c\uae30\uc774\uc9c0\ub9cc \uac19\uc774 \ubcf4\uba74 \uc88b\ub2e4.\n", "- [IPython in Depth, SciPy2013 Tutorial, Part 1 of 3](http://www.youtube.com/watch?v=xe_ATRmw0KM)" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from IPython.display import YouTubeVideo" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The IPython Notebook Revolution\n", "\n", "- \uc774 \ub3d9\uc601\uc0c1\uc5d0 \uad49\uc7a5\ud788 \uc7ac\ubbf8\uc788\ub294 \uac83\ub4e4\uc774 \ub9ce\uc774 \uc18c\uac1c\ub418\uc5b4 \uc788\uc2b5\ub2c8\ub2e4. \ucd94\ucc9c\ud569\ub2c8\ub2e4." ] }, { "cell_type": "code", "collapsed": false, "input": [ "YouTubeVideo('t_TzRaK9kpU')" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", " \n", " " ], "metadata": {}, "output_type": "pyout", "prompt_number": 5, "text": [ " " ] } ], "prompt_number": 5 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## [About my IPython in github](https://github.com/re4lfl0w/ipython)" ] } ], "metadata": {} } ] }