![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaVWHGdv5FUSm8ltbxYp5H0cegpjGhHcFhyphenhyphenTOiiNuo__4-gG3bgc_cq993mKSE0rjquRlxyuGWwPTULRLNQc5kCmDh44uDehmVdzPKjye3yjxp-Q1u9nCdVMK2ennw4Xa_-MuEzpNqGuGt/s400/rpy-cpy-ext-mod2.png)
It is now possible to use RPythonic to write CPython extension modules in RPython, RPythonic will work as the front-end that uses the PyPy translation toolchain to generate C code, compile it with GCC, package it in a cache directory with generated ctypes wrappers, and finally replace the decorated functions in-place in CPython.
RPythonic 0.2.8
RPython CPython Module API
import os, sys
sys.path.append('..')
import rpythonic
rpythonic.set_cache( '../cache' )
rpythonic.set_pypy_root( '../../pypy' )
################################
rpy = rpythonic.RPython()
@rpy.bind() # declare arg types is optional if,
def add( a=1, b=1000 ): # keyword defaults are given
return a+b
@rpy.bind(a=float, b=float)
def sub( a, b ):
return a-b
rpy.cache('test1') # only compiles if cache is dirty
########### now functions are using compiled version ###########
print add( 99, 88 )
Module Compiling and Caching
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigqDA7SuSCV3elQXME9mTl1FTWvvV5mLqViqRmjUIpG-5LEU8U_LfCeEr3YPfdpBSqOXc7prxDOIwwkidHEm5F4dggZscAAJ66hM2531ERxtdfob9x9sX807gK0ir5oXQbbkiRtKXArkH6/s400/rpy-cpy-ext-mod1.png)