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
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
camazotz-2017.3.20.1950.tar.gz
(15.1 kB
view details)
File details
Details for the file camazotz-2017.3.20.1950.tar.gz
.
File metadata
- Download URL: camazotz-2017.3.20.1950.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f56cc0f87c3d08b427337b32c9b4b120d97db3649dd96c40c036fb639f2a435 |
|
MD5 | fc2426634ca0ee67390a89d077b06e1b |
|
BLAKE2b-256 | a9a1b982a357af42da5fe179e98c760054c6d6004244a218296af6d278d4dd5c |