Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
3a6fbe0b
Commit
3a6fbe0b
authored
Mar 23, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added %%cython options.
parent
8ff9c50d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
docs/src/quickstart/build.rst
docs/src/quickstart/build.rst
+2
-0
docs/src/reference/compilation.rst
docs/src/reference/compilation.rst
+58
-0
No files found.
docs/src/quickstart/build.rst
View file @
3a6fbe0b
...
...
@@ -91,6 +91,8 @@ You can show Cython's code analysis by passing the ``--annotate`` option::
.. figure:: jupyter.png
For more information about the arguments of the ``%%cython`` magic, see
:ref:`Compiling with a Jupyter Notebook <compiling_notebook>`.
Using the Sage notebook
-----------------------
...
...
docs/src/reference/compilation.rst
View file @
3a6fbe0b
...
...
@@ -429,6 +429,64 @@ running session. Please check `Sage documentation
You can tailor the behavior of the Cython compiler by specifying the
directives below.
.. _compiling_notebook:
Compiling with a Jupyter Notebook
=================================
It's possible to compile code in a notebook cell with Cython.
For this you need to load the Cython magic::
%load_ext Cython
Then you can define a Cython cell by writing ``%%cython`` on top of it.
Like this::
%%cython
cdef int a = 0
for i in range(10):
a += i
print(a)
Note that each cell will be compiled individually. So if you use a package in a Cython
cell, you will have to import this package in the same cell. It's not enough to
have imported the package in a previous cell. Cython will tell you about it at
compilation time if you don't comply.
Additional allowable arguments to the Cython magic are:
============================================ =======================================================================================================================================
-a, --annotate Produce a colorized HTML version of the source.
-+, --cplus Output a C++ rather than C file.
-f, --force Force the compilation of a new module, even if the source has been previously compiled.
-3 Select Python 3 syntax
-2 Select Python 2 syntax
-c=COMPILE_ARGS, --compile-args=COMPILE_ARGS Extra flags to pass to compiler via the extra_compile_args.
--link-args LINK_ARGS Extra flags to pass to linker via the extra_link_args.
-l LIB, --lib LIB Add a library to link the extension against (can be specified multiple times).
-L dir Add a path to the list of libary directories (can be specified multiple times).
-I INCLUDE, --include INCLUDE Add a path to the list of include directories (can be specified multiple times).
-S, --src Add a path to the list of src files (can be specified multiple times).
-n NAME, --name NAME Specify a name for the Cython module.
--pgo Enable profile guided optimisation in the C compiler. Compiles the cell twice and executes it in between to generate a runtime profile.
--verbose Print debug information like generated .c/.cpp file location and exact gcc/g++ command invoked.
============================================ =======================================================================================================================================
.. _compiler-directives:
Compiler directives
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment