Re: [Python-Dev] expy: an expressway to extend Python
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
On Tue, Jul 21, 2009 at 11:22:19AM -0700, Yingjie Lan wrote:
@function(double) #return type: double def sqrt(x=double): #argument x: double
Python 3.0 has arguments and return value annotations: http://docs.python.org/3.0/whatsnew/3.0.html#new-syntax http://www.python.org/dev/peps/pep-3107/ Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
I think the point of his software is to make it easier to interface Python with C code, although his examples were probably not the best. Eric Entin On Tue, Jul 21, 2009 at 2:52 PM, Oleg Broytmann <phd@phd.pp.ru> wrote:
On Tue, Jul 21, 2009 at 11:22:19AM -0700, Yingjie Lan wrote:
@function(double) #return type: double def sqrt(x=double): #argument x: double
Python 3.0 has arguments and return value annotations:
http://docs.python.org/3.0/whatsnew/3.0.html#new-syntax http://www.python.org/dev/peps/pep-3107/
Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/eric%40ericentin.com
On Tue, Jul 21, 2009 at 04:26:52PM -0400, Eric Entin wrote:
I think the point of his software is to make it easier to interface Python with C code
I think I understand that. And I think this
@function(double) #return type: double def sqrt(x=double): #argument x: double
is how C functions are declared in Python, so I think annotations is the way to go for such declarations.
Python 3.0 has arguments and return value annotations:
http://docs.python.org/3.0/whatsnew/3.0.html#new-syntax http://www.python.org/dev/peps/pep-3107/
Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
participants (3)
-
Eric Entin -
Oleg Broytmann -
Yingjie Lan