[IronPython] [python] Re: Announcement: Project to getsomeCPython C extensions running under IronPython

Keith J. Farmer kfarmer at thuban.org
Thu Oct 18 00:25:16 CEST 2007

I think my point is that if you switch which dialect of C you're compiling with, such marshalling issues could (potentially) go away.


Again, I'm naïve here.  I've not made it my business to write native libraries for Python.  Just one, and that was years ago.


From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Curt Hagenlocher
Sent: Wednesday, October 17, 2007 3:22 PM
To: Discussion of IronPython
Subject: Re: [IronPython] [python] Re: Announcement: Project to getsomeCPython C extensions running under IronPython


On 10/17/07, Joe Mason <joe at notcharles.ca> wrote: 

On 10/17/07, Keith J. Farmer <kfarmer at thuban.org> wrote:
> Forgive my non-C-ness (it's been a long time since I wrote a native module
> for Python), but aren't you now buying into a major re-implementation of all
> the native Python standard library into C#? 

Couldn't the C/C# API just use IronPython objects and methods to
"implement" the Python standard library?


Yes, that would be the idea.


I think it's best when thinking about the architecture to have a specific example to refer to.  With that in mind, I'm going to repeat some code I wrote earlier in the thread (with a few modifications).


PyObject * ReverseSequence(PyObject * self, PyObject * args)


    PyObject * columns;

    if (!PyArg_ParseTuple(args, "O", &columns))


        return NULL;



    if (!PySequence_Check(columns))


        PyErr_SetString(PyExc_ValueError, "must be a sequence");

        return NULL;



    int length = PySequence_Length(columns);

    PyObject * result = PyTuple_New(length);

    for (int i = 0; i < length; i++)


        PyObject * value = PySequence_GetItem(sequence, i);

        // Don't remember if I need to INCREF value

        PySequence_SetItem(result, length - i - 1, value);



    return result;


Obviously, this isn't a "real-world" example, but it does show a few requirements for the compatibility layer.

1) The code expects a sequence.  What kind of data should we be allowed to pass to it from IronPython?

2) The code returns a "tuple".  How will this tuple be translated into a CLR object for consumption by IronPython?



Curt Hagenlocher

curt at hagenlocher.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20071017/e0acdd6f/attachment.html>

More information about the Ironpython-users mailing list