Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can you import C++ code into a Jupyter notebook?

I have a c++ function that I would like to use with Jupyter. I'd like to be able to call it from the main python thread. A minimal example would be something like the following:

#begin c code definition

#include <vector>
#include <iostream>
void printout(std::vector<int> input){
    std::vector<int>::iterator start;
    std::vector<int>::iterator end;
    for (start=input.begin();start!=end;++start){
        std::cout<< *start;
    std::cout<< std::endl;

int main(){
    std::vector<int> sample{1,2,3};
    return 0;

#switch back to python

I don't particularly need to call the function or run the main thread in C++, the main() is included to show how this function would be used in the C++ context. Broadly, I want something like the reverse of Cythonize