Re: [capi-sig] [Python-Dev] expy: an expressway to extend Python
21 Jul
2009
21 Jul
'09
6:22 p.m.
Hi,
Here is a brief example on how to use expy to implement the math module: (for more details, see http://expy.sf.net/)
"""Python math module by expy-cxpy.""" from expy import * expymodule(__name__)
#includes, defines, etc. @prologue def myprolog(): return """ #include <math.h> """
@function(double) #return type: double def sqrt(x=double): #argument x: double """sqrt(x) --> the square root of x.""" return "sqrt(x)" #as an expression
#a more terse way @function(double) def sin(x=double): """sin(x) --> the sin of x.""" pass #the deduced call: sin(x)
#more functions ...
expymodule(__name__) #end of module
5536
Age (days ago)
5536
Last active (days ago)
0 comments
1 participants
participants (1)
-
Yingjie Lan