Browse Source

Cython

pull/135/merge
Jure Šorn 2 months ago
parent
commit
3183af6b42
2 changed files with 12 additions and 12 deletions
  1. 10
      README.md
  2. 14
      index.html

10
README.md

@ -3511,18 +3511,18 @@ if __name__ == '__main__':
Appendix
--------
### Cython
**Library that compiles Python code into C.**
**Library that compiles Python-like code into C.**
```python
# $ pip3 install cython
import pyximport; pyximport.install()
import <cython_script>
<cython_script>.main()
import pyximport; pyximport.install() # Module that runs imported Cython scripts.
import <cython_script> # Script needs a '.pyx' extension.
<cython_script>.main() # Main() isn't automatically executed.
```
#### Definitions:
* **All `'cdef'` definitions are optional, but they contribute to the speed-up.**
* **Script needs to be saved with a `'pyx'` extension.**
* **Also supports C pointers via `'*'` and `'&'`, structs, unions, and enums.**
```python
cdef <ctype/type> <var_name> [= <obj>]

14
index.html

@ -55,7 +55,7 @@
<body>
<header>
<aside>December 9, 2024</aside>
<aside>December 10, 2024</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>
@ -2856,17 +2856,17 @@ px.line(df, x=<span class="hljs-string">'Date'</span>, y=<span class="hljs-strin
<div><h2 id="appendix"><a href="#appendix" name="appendix">#</a>Appendix</h2><div><h3 id="cython">Cython</h3><p><strong>Library that compiles Python code into C.</strong></p><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install cython</span>
<span class="hljs-keyword">import</span> pyximport; pyximport.install()
<span class="hljs-keyword">import</span> &lt;cython_script&gt;
&lt;cython_script&gt;.main()
<div><h2 id="appendix"><a href="#appendix" name="appendix">#</a>Appendix</h2><div><h3 id="cython">Cython</h3><p><strong>Library that compiles Python-like code into C.</strong></p><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install cython</span>
<span class="hljs-keyword">import</span> pyximport; pyximport.install() <span class="hljs-comment"># Module that runs imported Cython scripts.</span>
<span class="hljs-keyword">import</span> &lt;cython_script&gt; <span class="hljs-comment"># Script needs a '.pyx' extension.</span>
&lt;cython_script&gt;.main() <span class="hljs-comment"># Main() isn't automatically executed.</span>
</code></pre></div></div>
<div><h4 id="definitions">Definitions:</h4><ul>
<li><strong>All <code class="python hljs"><span class="hljs-string">'cdef'</span></code> definitions are optional, but they contribute to the speed-up.</strong></li>
<li><strong>Script needs to be saved with a <code class="python hljs"><span class="hljs-string">'pyx'</span></code> extension.</strong></li>
<li><strong>Also supports C pointers via <code class="python hljs"><span class="hljs-string">'*'</span></code> and <code class="python hljs"><span class="hljs-string">'&amp;'</span></code>, structs, unions, and enums.</strong></li>
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">cdef</span> &lt;ctype/type&gt; &lt;var_name&gt; [= &lt;obj&gt;]
<span class="hljs-keyword">cdef</span> &lt;ctype&gt;[n_elements] &lt;var_name&gt; [= &lt;coll_of_nums&gt;]
<span class="hljs-keyword">cdef</span> &lt;ctype/type/void&gt; &lt;func_name&gt;(&lt;ctype/type&gt; &lt;arg_name&gt;): ...
@ -2924,7 +2924,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the active
<footer>
<aside>December 9, 2024</aside>
<aside>December 10, 2024</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

Loading…
Cancel
Save