On 24 March 2010 10:22, Larry Riedel <Larry@...> wrote:
> For Python functions which are essentially the same
> as simple functions in the C API (POSIX, win32,
> etc), what are some advantages of having Jython use
> an interface layer which is *not* ctypes (besides
> backwards compatibility with older Jython versions)?
There isn't a whole lot of difference - the main advantage of
jnr-netdb over just using ctypes is it has fallbacks for platforms
where ctypes is not supported and/or restricted environments where
calling native functions is disallowed (e.g. google app engine).
You could also implement the fallbacks in jython code, (or ruby code)
- I just put it all in a java library to enable it to be re-used by
both jython and jruby.
Performance wise, calling native functions directly from ctypes versus
the jython->java->jaffl path is probably a wash, unless you're
micro-benchmarking. As long as you declare the ctypes function
signature, it will use similar paths to the non-x86asm-generating path
in jaffl, which is still pretty fast.
On the other hand, implementing this using ctypes would stress-test
the ctypes impl and help beat it into shape a bit faster.