'cdef'
definitions are optional, but they contribute to the speed-up.'pyx'
extension.cdef <ctype> <var_name> = <el>
-cdef <ctype>[n_elements] <var_name> = [<el>, <el>, ...]
-cdef <ctype/void> <func_name>(<ctype> <arg_name>): ...
+cdef <ctype> <var_name> = <el>
+cdef <ctype>[n_elements] <var_name> = [<el>, <el>, ...]
+cdef <ctype/void> <func_name>(<ctype> <arg_name>): ...
-cdef class <class_name>:
- cdef public <ctype> <attr_name>
+cdef class <class_name>:
+ cdef public <ctype> <attr_name>
def __init__(self, <ctype> <arg_name>):
self.<attr_name> = <arg_name>
-cdef enum <enum_name>: <member_name>, <member_name>, ...
+cdef enum <enum_name>: <member_name>, <member_name>, ...
Virtual Environments
System for installing libraries directly into project's directory.
$ python3 -m venv <name> # Creates virtual environment in current directory.
$ source <name>/bin/activate # Activates venv. On Windows run `<name>\Scripts\activate`.
diff --git a/parse.js b/parse.js
index 8c47a45..01765a2 100755
--- a/parse.js
+++ b/parse.js
@@ -300,7 +300,7 @@ const MARIO =
'if __name__ == \'__main__\':\n' +
' main()\n';
-const PLOTLY =
+const GROUPBY =
'>>> gb = df.groupby(\'z\'); gb.apply(print)\n' +
' x y z\n' +
'a 1 2 3\n' +
@@ -308,6 +308,20 @@ const PLOTLY =
'b 4 5 6\n' +
'c 7 8 6';
+const CYTHON_1 =
+ 'cdef <ctype> <var_name> = <el>\n' +
+ 'cdef <ctype>[n_elements] <var_name> = [<el>, <el>, ...]\n' +
+ 'cdef <ctype/void> <func_name>(<ctype> <arg_name>): ...\n';
+
+const CYTHON_2 =
+ 'cdef class <class_name>:\n' +
+ ' cdef public <ctype> <attr_name>\n' +
+ ' def __init__(self, <ctype> <arg_name>):\n' +
+ ' self.<attr_name> = <arg_name>\n';
+
+const CYTHON_3 =
+ 'cdef enum <enum_name>: <member_name>, <member_name>, ...\n';
+
const INDEX =
'Only available in the PDF. \n' +
'Ctrl+F / ⌘F is usually sufficient. \n' +
@@ -827,7 +841,10 @@ function fixHighlights() {
$(`code:contains(>>> logging.basicConfig()`).html(LOGGING_EXAMPLE);
$(`code:contains(samples_f = (sin(i *)`).html(AUDIO);
$(`code:contains(collections, dataclasses, enum, io, itertools)`).html(MARIO);
- $(`code:contains(>>> gb = df.groupby)`).html(PLOTLY);
+ $(`code:contains(>>> gb = df.groupby)`).html(GROUPBY);
+ $(`code:contains(cdef = )`).html(CYTHON_1);
+ $(`code:contains(cdef class :)`).html(CYTHON_2);
+ $(`code:contains(cdef enum : , , ...)`).html(CYTHON_3);
$(`ul:contains(Only available in)`).html(INDEX);
}