SIP Reference Guide-Introduction

Source: Internet
Author: User
Tags version control system

Introduced

This article is a reference guide for SIP4.18. SIP is a python tool used to automatically generate Python bindings to C/C + + libraries. SIP was originally developed in 1998 with PYQT for Python and QT GUI Toolkit, but is suitable for generating bindings for any C or C + + libraries.

This version of the SIP-generated bindings is available for Python version 2.3, including Python 3.x.

There are many other similar tools, such as Swig. In fact, SIP is so named because it originates from a small swig. But unlike Swig,sip, which is specifically designed to bind Python to C + +, it integrates as much of the functionality of C + + as possible.

SIP website: http://www.riverbankcomputing.com/software/sip
Here you can always find the latest stable version and the latest version of the document.

SIP can also be downloaded from the mercurial library: Http://www.riverbankcomputing.com/hg/sip.

License

SIP licensing is similar to Python, and also uses the GPL protocol (including V2 and V3). If you use SIP, it means that you must follow the GPL agreement.

Characteristics

The SIP and the bindings it generates have the following characteristics:

  • Fast loading, low memory footprint.
  • Automatic conversion of standard Python to C + + data types.
  • Overloading of functions and methods with different parameter signatures
  • Protected methods for accessing C + + classes
  • Ability to define a python subclass that inherits from the C + + type, including the C + + abstract class
  • The Python subclass can implement the __dtor__ () method to support the invocation of a C + + class's virtual destructor.
  • Supports common C + + functions, class methods, static class methods, virtual class methods, and abstract class methods.
  • C + + Virtual/abstract methods can be re-implemented in Python
  • Support for global and class variables
  • Supports Global and class operations
  • Support for C + + namespaces
  • Support for C + + templates
  • Supports C + + exceptions and translates to Python exceptions
  • Automatic generation of rich comparsion slots
  • Support Deprecation Warning
  • Supports the definition of a C + + class mapping with similar Python data types and automatically invokes
  • Supports automatic use of any available run-time type information to ensure that the Python instance object type matches the corresponding C + + object instance
  • You can convert a Python object between a type and a meta-type to wrap a C + + data type
  • Supports Python global interpreter locks, including indicating that a C + + function may be blocked, allowing the release of locks to be run by other Python threads.
  • Supports merging multiple simple or private related modules into a single module.
  • Supports the concept of C + + instance ownership (that is, which parts of the code are responsible for invoking the destructor of the instance), supporting changes in ownership during application run time.
  • Produces a C + + class library that itself builds on other C + + class libraries, allowing code integration and sharing between different bindings.
  • Supports the definition of a complex version control system with a set of canonical files. Allows control of the entire life cycle of a C + + class library, including specifying platform-specific optional features.
  • Supports the automatic generation of THE PEP 484 type hint stub file, which contains the description document in the specified file and allows external tools to be extracted and processed.
  • The copyright and authorization information declared in the specification file can be automatically included in all generated source code.
  • You can inherit the configuration from the Python-written build system, compile and install your own bindings, so you don't have to worry about the platform's specific problems.
  • Use Distutils to build your extended support.
  • SIP and its generated bindings can run in Unix,linux,windows,macos/x,android and iOS
SIP components

SIP consists of a number of different components.

    • SIP code Generator. It processes the. SIP specification file and generates C or c++bindings. The conversion details are referenced in the section using SIP (using SIP).
    • SIP header File (sip.h). It contains the specifications and data structures required to generate C and C + + code.
    • SIP module (sip.so or Sip.pyd). This is a Python extension module that is automatically imported by SIP-generated bindings and provides some common tool functions for them. For more information, see the Application Python API (Python API for applications)
    • SIP build System (sipconfig.py). It is a pure Python module that is created when the SIP is configured and encapsulates information about all systems. It contains directory names, compile and link flags, and version numbers, and it also contains some Python classes and functions. It helps you write configuration scripts for bindings.
    • SIP distutils Extension (sipdistutils.py). This is a distutils extension that you can use to build your extension module with Distutils. Used instead of manually writing a configuration script for the SIP build system. It can easily add. sip files to the list of files you need to build and extend. See Building extensions with Distutils (Building Your Extension with distutils) for details.
Preparation of SIP V5

The syntax of the SIP-specified file will be changed in SIP v5. The command-line options for the SIP code generator also change. To help users manage too much, the following methods are used

    • Whenever possible, all incompatible changes are implemented first in SIP v4.
    • After an incompatible change implementation, the old syntax is specified as deprecated (prompt warning), but is still supported in V4.
QT Support

SIP provides support for creating Digia-based QT toolkits.

The SIP code Generator understands the Signal/slot type-safe callback mechanism, which is used by QT to connect objects together. It allows the application to define a new Python signals, and allows the Python call object to be used like a slot.

SIP Reference Guide-Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.