PYTHON EXTENsION

Usually, there are two ways to make python extension.
  • wrapper the Python C API directly
  • make use of boost.python

HOw to make use of boost.python

  • Download the boost package from boost site
  • Compile boost.python
     1.sh bootstrap.sh(generate the bjam)
     2../bjam --toolset=gcc --with-python link=shared threading=multi variant=realease runtime-link=shared stage
        ./bjam --toolset=gcc --with-python link=shared threading=mulit variant=debug runtime-link=shared stage
  • OK, the boost_python.so is generated successfully
  • coding your codes with c/c++.
  • compile your boost.python extension project so that python could import&execute it.

BY the way

Now, we have finished the coding and we need to compile the boost.python extension project.

There are many build tools& ways to build projects.
  • use gcc/g++ command to compile in cmd
  • write the makefile 
  • cmake(good tool)
  • scons( better tool)

What is scons

SCONS is next generation building tool. It is written by python. So,  I introduce it to you.

Please see the example.

Why we use python c/c++ EXTENSION

1. performance
2.lazy
Made with Slides.com