\section{Interacting C and C++ with Python}
\subsection{Implementation}
We used \emph{ctypes}, which is a Python module to interact with other programming languages. It simplifies the loading of dynamic libraries (.so or .dll).\\\par
Its usage is not difficult, nevertheless one subtetly has been met with C++. 
When the compiler builds the binary objects, it will modify the name of the function, and therefore we can't use it directly. In the case of our function \emph{hello\_world}, the symbol's name in the binary is \emph{\_Z11hello\_worldv}.
Therefore, we need to declare the exported functions as \emph{extern "C"}.
 Adding this directive will force the compiler to keep its original name.

\subsection{Performances benchmarks}
\subsubsection{Presentation of the test}
The goal of the exercise was to compare the performances of three matrix multiplications implementations:
\begin{itemize}
  \item[\textbullet] In pure python
  \item[\textbullet] In C 
  \item[\textbullet] With Numpy's \emph{dot} method.
\end{itemize}\vspace{0.3cm}
We carried out a benchmark with the following protocol:
\begin{itemize}
  \item[\textbullet] Create 120 x 100 random matrices, with two matrix data types: 
  \begin{itemize}
    \item[\textbullet] Integers (long)
    \item[\textbullet] Floats (double)
  \end{itemize}
  \item[\textbullet] Execute multiplications 10 times per algorithm.
\end{itemize} 
\newpage
\subsubsection{Results and analysis}

\begin{figure}[!h]
	\begin{center}
		\includegraphics[width=12cm]{images/matrix_bench}
	\end{center}
	\caption{Benchmark results}
\end{figure}
The first thing that we can see is how slow python is. The execution time is up to 1000 times the C/Numpy's one. It is related to the fact that there is only bytecode, which is slower that native code.\\\par
Our naive C implementation has performances that are close to Numpy's one. Numpy's algirithms must be more optimized, but they probably have to handle more cases (matrix types...).\\\par
We can notice with those tests that float's computations are faster than integers. It shows that recent microprocessors are faster with floating points operations than with integers.\\\par
The main point that we can conclude from those tests is the slowness of Python compared to native code (C) in large loops. It confirms that Python is a glue language. We should use Numpy as much as we can: this library provides way faster operations. Python must be used to code quickly the algorithms without having to handle memory etc.