Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 03a858d7 authored by paugier's avatar paugier
Browse files

Cleanup 30_wrapping.ipynb

parent 0a9402f0
......@@ -2,7 +2,11 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Wrapping codes in static languages"
]
......@@ -11,16 +15,20 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We consider here wrapping two static languages: C and fortran.\n",
"We consider here wrapping two static languages: C and Fortran.\n",
"\n",
"We classically wrapp already existing code to access them via python. \n",
"We classically wrap already existing code to access them via Python. \n",
"\n",
"Depending on the language to wrap the tool to use are a bit different. \n"
"Depending on the language to wrap the tool to use are different. \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Fortran with [f2py](https://docs.scipy.org/doc/numpy/f2py/)\n",
"\n",
......@@ -348,7 +356,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Wrapping C code\n",
"--------------------------"
......@@ -388,9 +400,10 @@
]
},
{
"cell_type": "raw",
"cell_type": "markdown",
"metadata": {},
"source": [
"```python\n",
"from setuptools import setup, Extension\n",
"\n",
"version = \"0.1\"\n",
......@@ -413,7 +426,8 @@
" install_requires=[\"cffi\", \"numpy\", \"setuptools\"],\n",
" entry_points=\"\",\n",
" ext_modules=[module_distance],\n",
")\n"
")\n",
"```"
]
},
{
......@@ -485,15 +499,29 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Alternatives techniques: \n",
"------------------------------------\n",
"# Alternatives techniques: \n",
"\n",
"- Ctypes (standard library)\n",
"\n",
"- An historical tool is Swig (http://swig.org/). It allows to access C/C++ code from a variety of languages. \n",
" It requires the writing of an intermediate file that describes the C API.\n",
"\n",
"The historical tool is swig (http://swig.org/). It allows to access C/C++ code from a variety of languages. \n",
"It requires the writing of an intermediate file that describes the C API. \n",
"- Cython\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Wrapping C++ code\n",
"\n",
"From now wrapping C code can be done quite easily using CFFI as presented before. \n",
"- [pybind11](https://github.com/pybind/pybind11) Seamless operability between C++11 and Python.\n",
"\n",
"For wrapping C++ code, one will consider pybind11 (https://github.com/pybind/pybind11) that relies on features available from the 11 versions of C++. "
"- [cppyy](https://cppyy.readthedocs.io) Based on Cling (the C++ interpreter)"
]
}
],
......@@ -513,7 +541,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.2"
}
},
"nbformat": 4,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment