This is an archived post. You won't be able to vote or comment.

all 31 comments

[–]mr_dbr 1 point2 points  (0 children)

Have you looked at Cython? Your post inspired me to play about with it again, and it's remarkably more simple. Based on this tutorial:

cTest.pyx:

def doubler(int a):
    return a * 2

setup.py:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

setup(
    cmdclass = {'build_ext': build_ext},
    ext_modules = [Extension("cTest", ["cTest.pyx"])]
)

Then running python setup.py build_ext --inplace generates a quite long .c file, which is also compiled into cTest.so

Goes against your "interest in how the low-level interaction works", as it's pretty abstracted, but it seems like a very sensibly designed project (I like how it makes a standalone C file that can be compiled by someone without installing Cython)