def build_increment_ext():
    mod = ext_tools.ext_module('increment_ext')

    # Effectively a type declaration for 'a' in the following functions.
    a = 1

    ext_code = "return_val = PyInt_FromLong(a+1);"
    func = ext_tools.ext_function('increment',ext_code,['a'])
    mod.add_function(func)

    ext_code = "return_val = PyInt_FromLong(a+2);"
    func = ext_tools.ext_function('increment_by_2',ext_code,['a'])
    mod.add_function(func)

    mod.compile()
Build a simple extension with functions that increment numbers.
dataset/ETHPy150Open scipy/scipy/scipy/weave/examples/increment_example.py/build_increment_ext