<div><h2id="appendix"><ahref="#appendix"name="appendix">#</a>Appendix</h2><div><h3id="cython">Cython</h3><p><strong>Library that compiles Python-like code into C.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-comment"># $ pip3 install cython</span>
<spanclass="hljs-keyword">import</span> pyximport; pyximport.install() <spanclass="hljs-comment"># Module that runs imported Cython scripts.</span>
<spanclass="hljs-keyword">import</span><cython_script><spanclass="hljs-comment"># Script must be saved with '.pyx' extension.</span>
<spanclass="hljs-keyword">import</span> pyximport; pyximport.install() <spanclass="hljs-comment"># Module that runs Cython scripts.</span>
<spanclass="hljs-keyword">import</span><cython_script><spanclass="hljs-comment"># Script must have '.pyx' extension.</span>
</code></pre></div></div>
<div><h4id="allcdefdefinitionsareoptionalbuttheycontributetothespeedup">All <codeclass="python hljs"><spanclass="hljs-string">'cdef'</span></code> definitions are optional, but they contribute to the speed-up:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">cdef</span><ctype/type>[*]<var_name> [= <object>]
<div><h4id="allcdefdefinitionsareoptionalbuttheycontributetothespeedup">All <codeclass="python hljs"><spanclass="hljs-string">'cdef'</span></code> definitions are optional, but they contribute to the speed-up:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">cdef</span><type><var_name> [= <obj/var>] <spanclass="hljs-comment"># Either Python or C type variable.</span>
<spanclass="hljs-keyword">cdef</span><ctype> *<pointer_name> [= &<var>] <spanclass="hljs-comment"># Use <pointer>[0] to get the value.</span>
<spanclass="hljs-keyword">cdef</span><ctype>[size]<array_name>[= <coll/array>] <spanclass="hljs-comment"># Also `from cpython cimport array`.</span>
<spanclass="hljs-keyword">cdef</span><ctype> *<array_name> [= <coll/array>] <spanclass="hljs-comment"># Also `<<ctype> *> malloc(n_bytes)`.</span>
<pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">cdef</span><spanclass="hljs-class"><spanclass="hljs-keyword">class</span><<spanclass="hljs-title">class_name</span>>:</span><spanclass="hljs-comment"># Also `cdef struct <struct_name>:`.</span>
<spanclass="hljs-keyword">cdef</span><spanclass="hljs-keyword">public</span><type> [*]<attr_name><spanclass="hljs-comment"># Also `... <ctype> [*]<field_name>`.</span>
<spanclass="hljs-function"><spanclass="hljs-keyword">def</span><spanclass="hljs-title">__init__</span><spanclass="hljs-params">(self, <type><arg_name>)</span>:</span><spanclass="hljs-comment"># Also `cdef __dealloc__(self):`.</span>
self.<attr_name> = <arg_name><spanclass="hljs-comment"># Also `... free(<pointer/array>)`.</span>
</code></pre>
<div><h3id="virtualenvironments">Virtual Environments</h3><p><strong>System for installing libraries directly into project's directory.</strong></p><pre><codeclass="python hljs">$ python3 -m venv NAME <spanclass="hljs-comment"># Creates virtual environment in current directory.</span>
$ source NAME/bin/activate <spanclass="hljs-comment"># Activates it. On Windows run `NAME\Scripts\activate`.</span>
@ -2939,7 +2938,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the active
'<span class="hljs-keyword">cdef</span> <type> <var_name> [= <obj/var>] <span class="hljs-comment"># Either Python or C type variable.</span>\n'+
'<span class="hljs-keyword">cdef</span> <ctype> *<pointer_name> [= &<var>] <span class="hljs-comment"># Use <pointer>[0] to get the value.</span>\n'+