Skip to content

Commit 3183af6

Browse files
committed
Cython
1 parent 907f39f commit 3183af6

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3511,18 +3511,18 @@ if __name__ == '__main__':
35113511
Appendix
35123512
--------
35133513
### Cython
3514-
**Library that compiles Python code into C.**
3514+
**Library that compiles Python-like code into C.**
35153515

35163516
```python
35173517
# $ pip3 install cython
3518-
import pyximport; pyximport.install()
3519-
import <cython_script>
3520-
<cython_script>.main()
3518+
import pyximport; pyximport.install() # Module that runs imported Cython scripts.
3519+
import <cython_script> # Script needs a '.pyx' extension.
3520+
<cython_script>.main() # Main() isn't automatically executed.
35213521
```
35223522

35233523
#### Definitions:
35243524
* **All `'cdef'` definitions are optional, but they contribute to the speed-up.**
3525-
* **Script needs to be saved with a `'pyx'` extension.**
3525+
* **Also supports C pointers via `'*'` and `'&'`, structs, unions, and enums.**
35263526

35273527
```python
35283528
cdef <ctype/type> <var_name> [= <obj>]

index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
<body>
5757
<header>
58-
<aside>December 9, 2024</aside>
58+
<aside>December 10, 2024</aside>
5959
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
6060
</header>
6161

@@ -2856,17 +2856,17 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
28562856

28572857

28582858

2859-
<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>
2860-
<span class="hljs-keyword">import</span> pyximport; pyximport.install()
2861-
<span class="hljs-keyword">import</span> &lt;cython_script&gt;
2862-
&lt;cython_script&gt;.main()
2859+
<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>
2860+
<span class="hljs-keyword">import</span> pyximport; pyximport.install() <span class="hljs-comment"># Module that runs imported Cython scripts.</span>
2861+
<span class="hljs-keyword">import</span> &lt;cython_script&gt; <span class="hljs-comment"># Script needs a '.pyx' extension.</span>
2862+
&lt;cython_script&gt;.main() <span class="hljs-comment"># Main() isn't automatically executed.</span>
28632863
</code></pre></div></div>
28642864

28652865

28662866

28672867
<div><h4 id="definitions">Definitions:</h4><ul>
28682868
<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>
2869-
<li><strong>Script needs to be saved with a <code class="python hljs"><span class="hljs-string">'pyx'</span></code> extension.</strong></li>
2869+
<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>
28702870
</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;]
28712871
<span class="hljs-keyword">cdef</span> &lt;ctype&gt;[n_elements] &lt;var_name&gt; [= &lt;coll_of_nums&gt;]
28722872
<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 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
29242924

29252925

29262926
<footer>
2927-
<aside>December 9, 2024</aside>
2927+
<aside>December 10, 2024</aside>
29282928
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29292929
</footer>
29302930

0 commit comments

Comments
 (0)