From 56d36433b4c308d57c834a741ad1b72d3a9ab7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 2 Jul 2020 11:11:01 +0200 Subject: [PATCH] Cython --- README.md | 17 +++++++---------- index.html | 22 ++++++++++------------ 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 018d04c..d1e0326 100644 --- a/README.md +++ b/README.md @@ -3428,8 +3428,15 @@ Cython ```python # $ pip3 install cython +import pyximport; pyximport.install() +import +.main() ``` +### Definitions +* **All `'cdef'` definitions are optional, but they contribute to the speed-up.** +* **Script needs to be saved with a `'pyx'` extension.** + ```python cdef = cdef [n_elements] = [, , ...] @@ -3446,16 +3453,6 @@ cdef class : ```python cdef enum : , , ... ``` -* **All `'cdef'` definitions are optional, but they contribute to the speed-up.** -* **Script needs to be saved with a `'pyx'` extension.** - -#### Running Cython code: -```python -#!/usr/bin/env python3 -import pyximport; pyximport.install() -import -.main() -``` Basic Script Template diff --git a/index.html b/index.html index d28a9b3..ac3aac6 100644 --- a/index.html +++ b/index.html @@ -2912,13 +2912,21 @@ plotly.express.line(df, x='Date', y=

#Cython

Library that compiles Python code into C.

# $ pip3 install cython
+import pyximport; pyximport.install()
+import <cython_script>
+<cython_script>.main()
 
-
cdef <type> <var_name> = <el>
+

Definitions

    +
  • All 'cdef' definitions are optional, but they contribute to the speed-up.
  • +
  • Script needs to be saved with a 'pyx' extension.
  • +
cdef <type> <var_name> = <el>
 cdef <type>[n_elements] <var_name> = [<el_1>, <el_2>, ...]
 cdef <type/void> <func_name>(<type> <arg_name_1>, ...):
-
+
+ +
cdef class <class_name>:
     cdef public <type> <attr_name>
     def __init__(self, <type> <arg_name>):
@@ -2926,16 +2934,6 @@ cdef <type/void> <func_name>(<type> <arg_name_1>, ...):
 
cdef enum <enum_name>: <member_name_1>, <member_name_2>, ...
 
-
    -
  • All 'cdef' definitions are optional, but they contribute to the speed-up.
  • -
  • Script needs to be saved with a 'pyx' extension.
  • -
-

Running Cython code:

#!/usr/bin/env python3
-import pyximport; pyximport.install()
-import <pyx_script_name>
-<pyx_script_name>.main()
-
-

#Basic Script Template

#!/usr/bin/env python3
 #
 # Usage: .py