Skip to main content

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

Project description

IncludeCPP - C++ Performance in Python, Zero Hassle

Write performance-critical code in C++, use it in Python like native modules. No boilerplate, no manual bindings, no complexity.

Installation

pip install IncludeCPP

Quick Start

1. Initialize Project

python -m includecpp init

Creates:

  • cpp.proj - Configuration
  • include/ - C++ source files
  • plugins/ - Module definitions

2. Auto-Generate Plugin Definition

python -m includecpp plugin fast_list include/fast_list.cpp include/fast_list.h

Automatically generates plugins/fast_list.cp by analyzing your C++ code.

3. Build

python -m includecpp rebuild

4. Use in Python

from includecpp import CppApi

api = CppApi()
fast_list = api.include("fast_list")

my_list = fast_list.FastList()
my_list.append(42)

CLI Commands

init

Initialize new IncludeCPP project.

python -m includecpp init

plugin

Auto-generate .cp plugin definition from C++ files.

python -m includecpp plugin <name> <file1.cpp> [file2.h] [...]

Options:

  • -p, --private <func> - Exclude function from public API

Example:

python -m includecpp plugin math_tools include/math.cpp include/math.h -p InternalHelper

rebuild

Build or rebuild C++ modules.

python -m includecpp rebuild [OPTIONS]

Options:

  • --clean - Force clean rebuild (ignore incremental cache)
  • --full - Complete rebuild including generator and all caches
  • --verbose - Detailed build output
  • --no-incremental - Disable incremental builds
  • --parallel/--no-parallel - Enable/disable parallel compilation (default: enabled)
  • -j, --jobs <N> - Max parallel jobs (default: 4)
  • -m, --modules <name> - Rebuild specific modules only

Examples:

python -m includecpp rebuild --full --verbose
python -m includecpp rebuild -m crypto -m networking

install

Install community modules from GitHub.

python -m includecpp install <module_name>

Downloads from https://github.com/liliassg/IncludeCPP/tree/main/minstall/<module_name>

Example:

python -m includecpp install fast_list
python -m includecpp rebuild

Features

VSCode IntelliSense Support

Automatic type hint generation for full IDE autocomplete.

Enable/Disable in cpp.proj:

{
  "CPI-IntelliSense": true
}

When enabled, .pyi stub files are generated during rebuild, providing:

  • Function signatures
  • Class methods and attributes
  • Module-level exports
  • Full VSCode autocomplete

Template Structs (v2.0+)

template<typename T>
struct Point {
    T x;
    T y;
};
geometry STRUCT(Point) TYPES(int, float) {
    FIELD(T, x)
    FIELD(T, y)
}

Auto-generates:

  • .to_dict() method
  • .from_dict() static method
  • Full type hints

Module Dependencies

DEPENDS(math_utils, geometry)

Build system handles dependency order automatically.

Multi-File Modules

SOURCE(module.cpp helpers.cpp utils.cpp) my_module

Incremental Builds

SHA256-based change detection. Only rebuilds modified modules.

Cross-Platform

  • Windows (MSVC, MinGW, g++)
  • Linux (g++, clang++)
  • macOS (clang++)

Type Support

  • Basic: int, float, double, bool, string
  • STL: vector, map, set, array, pair
  • Custom: Structs, classes, templates

Configuration

cpp.proj:

{
  "project": "MyProject",
  "version": "1.0.0",
  "include": "/include",
  "plugins": "/plugins",
  "compiler": {
    "standard": "c++17",
    "optimization": "O3",
    "flags": ["-Wall", "-pthread"]
  },
  "types": {
    "common": ["int", "float", "double", "string"]
  },
  "threading": {
    "enabled": true,
    "max_workers": 8
  },
  "CPI-IntelliSense": true
}

Advanced Examples

Class with Methods

class Crypto {
public:
    std::string md5(const std::string& data);
    std::string sha256(const std::string& data);
};
crypto CLASS(Crypto) {
    METHOD(md5)
    METHOD(sha256)
}
crypto = api.include("crypto")
hash = crypto.Crypto().md5("hello")

Template Functions

template<typename T>
T maximum(T a, T b) {
    return a > b ? a : b;
}
math TEMPLATE_FUNC(maximum) TYPES(int, float, string)
math.maximum(10, 20)        # 20
math.maximum(1.5, 2.3)      # 2.3
math.maximum("a", "z")      # "z"

Requirements

  • Python: 3.8+
  • C++ Compiler: g++, clang++, or MSVC
  • CMake: 3.15+ (optional, falls back to direct compilation)
  • pybind11: Installed automatically

Build System

  • AppData Storage: Builds stored in %APPDATA%\IncludeCPP (Windows) or ~/.local/share/includecpp (Linux)
  • Clean Projects: Source directory stays clean
  • Incremental: SHA256-based change detection
  • Parallel: Multi-threaded compilation
  • Caching: Reuses unchanged binaries

Why IncludeCPP?

For developers who:

  • Need C++ performance with Python productivity
  • Don't want complex build configurations
  • Value fast iteration and simple workflows
  • Want production-ready bindings without boilerplate

Not for:

  • Pure Python projects
  • When CPython extensions are overkill
  • Projects requiring custom build pipelines

License: MIT Version: 2.0.5 Status: Production Ready Repository: https://github.com/liliassg/IncludeCPP

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-2.0.5.tar.gz (49.3 kB view details)

Uploaded Source

Built Distribution

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

includecpp-2.0.5-py3-none-any.whl (59.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for includecpp-2.0.5.tar.gz
Algorithm Hash digest
SHA256 17bed9fbaead4cd8d612773733996d2fc95f9549263217d647c746428d5c4805
MD5 1e8134c62a80ce004bbbba6c976a2c06
BLAKE2b-256 eea1140d2fc372834ddd1e6c75b00f0f71e05e84251b22521de7406f91f1af99

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for includecpp-2.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6e52557061d1180af1220fd8ea622dba13b726cbf11198fa03df2c6b7b629a38
MD5 8c70b0efa23a8516d917354db5427497
BLAKE2b-256 81d4a4e66e2b1b889ffc45f1f826ab9f3f13dfc90d59883097856244380a08b3

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