Skip to main content

template Python program

Project description

camazotz

C code in Python code

introduction

Camazotz compiles and loads C code in Python code. Specifically, it enables insertion of C code directly into Python files, which can be dynamically linked and called via ctypes.

setup

pip install camazotz

usage

export CC="gcc"
import camazotz

library = camazotz.C(
    """
    #include <stdio.h>

    int factorial(int x){
        int result = 1;
        while (x > 1){
            result *= x;
            x--;
        }

        return result;
    }
    """
)

function_factorial = library["factorial"]
print("5! =", function_factorial(5))
print("4! =", function_factorial(4))

Project details


Download files

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

Files for camazotz, version 2017.3.20.1950
Filename, size File type Python version Upload date Hashes
Filename, size camazotz-2017.3.20.1950.tar.gz (15.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page