Stefan's work to support the C extension API is exciting and it will also allow us to support cython, in a fashion similar to PyPy [1]. The C ext API is well designed and robust; the biggest concern that PyPy has raised is how funneling through the C ext API impacts the ability to inline and thus performance. This might be of a less issue for Jython in that we can use sun.misc.Unsafe's support for intrinsics (Java methods that are directly replaced with machine instructions).

The current ctypes in Jython is unfortunately just a stub. We do use jnr in Jython, and there's support for jffi [2], which is the successor to the JNA project. jnr is easy to use [3]; someone should come up with an example of using it from Jython :), although it requires some Java side definition for say structs and functions to take advantage of annotations and type specifications.

Wayne Meissner, the author of jffi, spent some time trying to support ctypes, but it didn't pan out. As I understand it in my conversations with the PyPy community, ctypes is a bit of a mess design wise. It certainly made my brain hurt when we were going through the corner cases 5 years ago. PyPy got somewhat more progress with a *lot* of effort, but their implementation of ctypes is still very restricted. Essentially they can run pyglet [4].

[4]: http://pypy.readthedocs.org/en/latest/ctypes-implementation.html

On Mon, Sep 9, 2013 at 7:32 AM, Stefan Richthofer <Stefan.Richthofer@gmx.de> wrote:
Dear Jonathan,
I am currently working on a project doing exactly what you're asking for.
Take a look at www.jyni.org .
I am not working on a ctypes for Jython, but for a complete support
of native CPython extensions (thus ideally the original ctypes should be usable).
However my main goal is supporting numpy, so I focus on numpy-relevant API first.
If you have need for another module, feel free to file a feature request to
contact@jyni.org .

The project is still alpha state, but I hope to be able to load numpy within one month
or so. Development is done on linux, so don't expect a cross platform version too soon
(I hope, I can start work on cross platform versions in early 2014).

>>for 2.5 in particular
I am directly targeting the 2.7 release of Jython. Ideally JyNI would reach beta state
when Jython 2.7 is released. I expect, 2.5 will be near end of life anyway when JyNI
will be released.

Cheers

Stefan



> Gesendet: Montag, 09. September 2013 um 13:53 Uhr
> Von: "Jonathan Hale" <Jonathan.Hale@uni-konstanz.de>
> An: jython-dev@lists.sourceforge.net
> Betreff: [Jython-dev] Questions regarding ctypes/C-API
>
> Dear jython developers!
>
>
> I have some questions regarding the C-API of jython. I hope this is the right place for that.
>
> First of all: Is anybody working on this feature (for 2.5 in particular) or is ist still "Future?".
> If not, does anybody have an idea or plan for how this should be implemented? As far as I know, there is a placeholder somewhere?
>
> I guess implementing this module would enable usage of many libraries. Maybe even Cython extensions?
>
>
> Sincerely,
> Jonathan Hale
>
>
> PS:
> You may want to fix the link on <https://wiki.python.org/jython/RoadMap> to the ctypes module under "Future?":
> <http://docs.python.org/2/library/ctypes.html#module-ctypes>
>
> ------------------------------------------------------------------------------
> Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
> Discover the easy way to master current and previous Microsoft technologies
> and advance your career. Get an incredible 1,500+ hours of step-by-step
> tutorial videos with LearnDevNow. Subscribe today and save!
> http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
> _______________________________________________
> Jython-dev mailing list
> Jython-dev@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jython-dev
>

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
Jython-dev mailing list
Jython-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-dev