Skip to main content

Professional C++ Python bindings with type-generic templates and native threading

Project description

IncludeCPP - Professional C++ Python Bindings

Professional C++ ↔ Python binding system with type-generic templates, native threading support, and maximum performance.

Features

  • Type-Generic System: Functions work with ANY type automatically

    algorithms.fast_sort([1,2,3])      # int version
    algorithms.fast_sort([1.5, 2.3])   # float version
    algorithms.fast_sort(["a","b"])    # string version
    
  • Native Threading with GIL Release: True parallelism

    game = CPP.include("threading").GameEngine()
    CPP.threadThis(game)  # Runs in C++ thread with GIL released
    
  • Dynamic Configuration: cpp.proj JSON configuration

  • AppData Build System: Clean separation of project and build artifacts

  • CLI Tool: includecpp --rebuild for easy building

  • Zero Overhead: Template instantiation eliminates runtime overhead

Installation

pip install IncludeCPP

Quick Start

1. Initialize Project

cd YourProject
includecpp init

This creates:

  • cpp.proj - Configuration file
  • include/ - Your C++ source files
  • plugins/ - Plugin definitions (.cp files)

2. Create C++ Module

include/mymodule.cpp:

#include <vector>
#include <algorithm>

namespace includecpp {

std::vector<int> custom_sort(const std::vector<int>& data) {
    std::vector<int> result = data;
    std::sort(result.begin(), result.end());
    return result;
}

}

plugins/mymodule.cp:

SOURCE(include/mymodule.cpp) mymodule

PUBLIC(
    mymodule FUNC(custom_sort)
)

3. Build

includecpp --rebuild

Build artifacts go to:

  • Windows: %APPDATA%/YourProject&gcc-build-proj/
  • Linux: ~/.local/share/includecpp/YourProject&gcc-build-proj/

4. Use in Python

import IncludeCPP as cpp

CPP = cpp.CppApi()
CPP.noFeedback()  # Disable warnings

mymodule = CPP.include("mymodule")
result = mymodule.custom_sort([5, 2, 9, 1])
print(result)  # [1, 2, 5, 9]

Type-Generic Templates

# plugins/algorithms.cp
SOURCE(include/algorithms.cpp) && HEADER(include/algorithms.h) algorithms

PUBLIC(
    algorithms TEMPLATE_FUNC(fast_sort) TYPES(int, float, double, string)
)

Configuration

cpp.proj (auto-created by includecpp init):

{
  "project": "MyProject",
  "version": "1.0.0",
  "include": "/include",
  "plugins": "/plugins",
  "compiler": {
    "standard": "c++17",
    "optimization": "O3",
    "flags": ["-Wall", "-pthread"]
  }
}

Requirements

  • Python >= 3.8
  • C++ compiler (g++, clang++, or MSVC)
  • pybind11 >= 2.11.0
  • CMake >= 3.15

License

MIT License

Links

Example: Complete Module

See the examples/ directory for complete working examples including:

  • Type-generic algorithms
  • Threading with GIL release
  • Map and Array containers
  • Custom C++ classes

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

includecpp-1.1.3.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

includecpp-1.1.3-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file includecpp-1.1.3.tar.gz.

File metadata

  • Download URL: includecpp-1.1.3.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for includecpp-1.1.3.tar.gz
Algorithm Hash digest
SHA256 864edd088e0a1ca43af62d8284a50aee1ada73d40cdb9638ebc02953d4a2c5a7
MD5 9b094b672457a0416ecca62e40bb978d
BLAKE2b-256 25446bf1d82f7fc7aa42caee34bdcb386b1cfd5c4bd9b5cd9b76098ca81db031

See more details on using hashes here.

File details

Details for the file includecpp-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: includecpp-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for includecpp-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ff5a68b5a6ccb6d2d8272fe4985728cf092c3a0249e53d87e76f3eba3c57b9dd
MD5 4adf335182f532cc87418e11f4b6bc5a
BLAKE2b-256 50ebea1a2e7463c9511141953343e0f2cb099d31bc432b899cd2225c18e40284

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page