On 02/10/2016 14:43, nicolasessisbre...@gmail.com wrote:
**Is Fython a full-featured Python implementation that compiles to Fortran, or
a thin wrapper around Fortran that uses Python syntax, or something in between?
It's something in between. Fython is a programming langugage with its own
syntax. For example
def mean:
int in n
real in x(n)
real out r
int i
for i in [1, n]:
r = x[i] + x[n-i+1] # a funky mean
One problem with using very similar syntax for distinct languages is
that it can get confusing.
In Python, that loop has two iterations. Here presumably it has n
iterations.
The syntax is very close to Python. All variables must be typed, because this
is the key to performance. To use this program in Python, we do
from fython import *
m = load('.mean') # assuming previous code is in file: mean.fy
n = Int(3)
x = Real(value=[1,2,3])
r = Real()
m.value(n,x,r)
print(r)
So Fython provides a wrapper around itself for Python to use.
How does it work in practice: does an actual Fortran compiler need to be
invoked? (And do you need to install one, or is it all included?)
If so, at what point in the above example is it invoked? Is it every
time you run that Python code, or will the load() used a cached copy of
the compiled mean.fy?
--
Bartc
--
https://mail.python.org/mailman/listinfo/python-list