Thinking Hybrid - Python/C++ Integration

download Thinking Hybrid - Python/C++ Integration

of 35

  • date post

    17-Aug-2014
  • Category

    Technology

  • view

    10.502
  • download

    23

Embed Size (px)

description

Talk on integrating native C++ sensibly into Python for ease of use of the code base. Inheriting from C++ classes, overriding functionality, automatically generating the bindings using Py++ and SCons. Code demonstrated in the presentation can be found here: http://www.kloss-familie.de/moin/TalksPresentations

Transcript of Thinking Hybrid - Python/C++ Integration

  • Python Extending/Integrating A Real World Example Tips Summary Python where we can, C++ where we must Source: http://xkcd.com/353/ Guy K. Kloss Python where we can,C++ where we must 1/28
  • Python Extending/Integrating A Real World Example Tips Summary Python where we can, C++ where we must Guy K. Kloss BarCamp Auckland 2007 15 December 2007 Quote: Alex Martelli, Senior Google Developer Guy K. Kloss Python where we can,C++ where we must 2/28
  • Python Extending/Integrating A Real World Example Tips Summary Outline 1 Python 2 Extending/Integrating 3 A Real World Example 4 Tips Guy K. Kloss Python where we can,C++ where we must 3/28
  • Python Extending/Integrating A Real World Example Tips Summary Outline 1 Python 2 Extending/Integrating 3 A Real World Example 4 Tips Guy K. Kloss Python where we can,C++ where we must 4/28
  • Python Extending/Integrating A Real World Example Tips Summary What is Python? Objectoriented Dynamic Easy to learn syntax High-level data types Scripting language Embeddable in C/C++ Guy K. Kloss Python where we can,C++ where we must 5/28
  • Python Extending/Integrating A Real World Example Tips Summary Python vs. Java (or C++) No compilation Fast editbuilddebug cycle Dynamic Typing No need to declare variables for use Easy Syntax No curly braces, no semicolons, no new . . . Embeddable Scripting support for your applications Interactive Create, view, change objects at runtime 50% less code Compact and natural syntax 300% more productive Closer to the way you think Guy K. Kloss Python where we can,C++ where we must 6/28
  • Python Extending/Integrating A Real World Example Tips Summary Why Python? Mixable Extend Python with components written in C++, Java, C Embed Python into your application and call it from C/C++ Platform independent Powerful Ease of use of scripting language Built-in object types Extensive libraries Automatic memory management Modules, classes and exceptions Guy K. Kloss Python where we can,C++ where we must 7/28
  • Python Extending/Integrating A Real World Example Tips Summary What is Python used for? System Utilities System admin tools, portable shell scripts Internet Scripting CGI scripts, parse HTML, process XML, email tools User Interfaces (UIs) & rapid prototyping Component Glue Scripting for apps, COM scripting Distributed Programming Web Services, COM, CORBA, XMLRPC Database Programming Scientic Computing PyODE, NumPy, SciPy, PyMol, . . . Image Processing Python Image Library OpenGL Programming, Writing Games PyOpenGL, Panda3D, PyOgre, Py3d, VisualPython Artical Intelligence Guy K. Kloss Python where we can,C++ where we must 8/28
  • Python Extending/Integrating A Real World Example Tips Summary Why Native Code? C/C++, Fortran (and Java, C#, ...) Performance Binding to legacy code (Existing) Applications/Libraries . . . ... want to be scripted ... want to be tested ... want to be re-used Guy K. Kloss Python where we can,C++ where we must 9/28
  • Python Extending/Integrating A Real World Example Tips Summary Outline 1 Python 2 Extending/Integrating 3 A Real World Example 4 Tips Guy K. Kloss Python where we can,C++ where we must 10/28
  • Python Extending/Integrating A Real World Example Tips Summary What if I could . . . Use this code more eectively . . . ? [NaSt2D demonstration (native executable)] Guy K. Kloss Python where we can,C++ where we must 11/28
  • Python Extending/Integrating A Real World Example Tips Summary Extending/Integration The Contestants: The classic way . . . Extending and Embedding the Python Interpreter The new way . . . Python ctypes SWIG Boost.Python Others: SIP Pythonizer SILOON (Pyrex) Extensions also for Java, C#, Fortran, . . . available Guy K. Kloss Python where we can,C++ where we must 12/28
  • Python Extending/Integrating A Real World Example Tips Summary Extending/Integration The Contestants: The classic way . . . Extending and Embedding the Python Interpreter The new way . . . Python ctypes SWIG Boost.Python Others: SIP Pythonizer SILOON (Pyrex) Extensions also for Java, C#, Fortran, . . . available Guy K. Kloss Python where we can,C++ where we must 12/28
  • Python Extending/Integrating A Real World Example Tips Summary Extending/Integration The Contestants: The classic way . . . Extending and Embedding the Python Interpreter The new way . . . Python ctypes SWIG Boost.Python Others: SIP Pythonizer SILOON (Pyrex) Extensions also for Java, C#, Fortran, . . . available Guy K. Kloss Python where we can,C++ where we must 12/28
  • Python Extending/Integrating A Real World Example Tips Summary Extending/Integration The Contestants: The classic way . . . Extending and Embedding the Python Interpreter The new way . . . Python ctypes SWIG Boost.Python Others: SIP Pythonizer SILOON (Pyrex) Extensions also for Java, C#, Fortran, . . . available Guy K. Kloss Python where we can,C++ where we must 12/28
  • Python Extending/Integrating A Real World Example Tips Summary Extending/Integration The Contestants: The classic way . . . Extending and Embedding the Python Interpreter The new way . . . Python ctypes SWIG Boost.Python Others: SIP Pythonizer SILOON (Pyrex) Extensions also for Java, C#, Fortran, . . . available Guy K. Kloss Python where we can,C++ where we must 12/28
  • Python Extending/Integrating A Real World Example Tips Summary Boost.Python Thinking Hybrid with Boost.Python Bottom up and . . . Top down possible Develop quickly Resolve bottle necks Donald Knuths: Premature optimisation is the root of all evil. or: Dont Optimise Now! Guy K. Kloss Python where we can,C++ where we must 13/28
  • Python Extending/Integrating A Real World Example Tips Summary Boost.Python Thinking Hybrid with Boost.Python Bottom up and . . . Top down possible Develop quickly Resolve bottle necks Donald Knuths: Premature optimisation is the root of all evil. or: Dont Optimise Now! Guy K. Kloss Python where we can,C++ where we must 13/28
  • Python Extending/Integrating A Real World Example Tips Summary Boost.Python Thinking Hybrid with Boost.Python Bottom up and . . . Top down possible Develop quickly Resolve bottle necks Donald Knuths: Premature optimisati