Experimental C Extensions from IronPython with Python.NET - code and article
Hello all, I've just posted the experimental code for accessing CPython extensions from IronPython. It uses the embedding wrapper from Python.NET so I thought I would let you know. :-) Blog entry: http://www.voidspace.org.uk/python/weblog/arch_d7_2007_10_20.shtml#e862 Article: http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml Despite some serious limitations it works! I have already had matplotlib with numpy and Tkinter working from IronPython. We're evaluating to see if this should be the basis of our 'C Extensions from IronPython' project. All the best, Michael http://www.manning.com/foord
Michael Foord wrote:
I've just posted the experimental code for accessing CPython extensions from IronPython. It uses the embedding wrapper from Python.NET so I thought I would let you know. :-)
Blog entry: http://www.voidspace.org.uk/python/weblog/arch_d7_2007_10_20.shtml#e862 Article: http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml
Despite some serious limitations it works! I have already had matplotlib with numpy and Tkinter working from IronPython.
We're evaluating to see if this should be the basis of our 'C Extensions from IronPython' project.
Nice work, Michael! :) I've been doing some work on PythonDotNet over the last couple for months, mostly porting it to Python 2.3, 2.5 and 2.6, getting Mono and UCS-4 builds done and straighting out bugs. I've also played with the idea to embed PythonDotNet in IronPython but I haven't got as far as you. And to be honest I haven't thought that it's so easy to get the basics done. I'm still fighting with IronPython on Mono. I have been trying to use a different approach to exchange data between IronPython and PythonDotNet/CPython. I used the same approach as the processing package. It uses pickles to exchange data across multiple Python processes. Christian
that looks pretty slick - congrats! -Brian ________________________________ From: pythondotnet-bounces@python.org on behalf of Michael Foord Sent: Tue 10/23/2007 6:17 PM To: pythondotnet@python.org Subject: [Python.NET] Experimental C Extensions from IronPython with Python.NET - code and article Hello all, I've just posted the experimental code for accessing CPython extensions from IronPython. It uses the embedding wrapper from Python.NET so I thought I would let you know. :-) Blog entry: http://www.voidspace.org.uk/python/weblog/arch_d7_2007_10_20.shtml#e862 Article: http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml Despite some serious limitations it works! I have already had matplotlib with numpy and Tkinter working from IronPython. We're evaluating to see if this should be the basis of our 'C Extensions from IronPython' project. All the best, Michael http://www.manning.com/foord _________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
This is too sweet for words. One of the main reasons I haven't moved over to IronPython is that I want to use numpy. Nice Going! Mathew Michael Foord wrote:
Hello all,
I've just posted the experimental code for accessing CPython extensions from IronPython. It uses the embedding wrapper from Python.NET so I thought I would let you know. :-)
Blog entry: http://www.voidspace.org.uk/python/weblog/arch_d7_2007_10_20.shtml#e862 Article: http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml
Despite some serious limitations it works! I have already had matplotlib with numpy and Tkinter working from IronPython.
We're evaluating to see if this should be the basis of our 'C Extensions from IronPython' project.
All the best,
Michael http://www.manning.com/foord
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
Mathew Yeates wrote:
This is too sweet for words. One of the main reasons I haven't moved over to IronPython is that I want to use numpy. Nice Going!
Hey - well if someone uses it I might actually maintain it... :-) For passing lots of data in and out it will probably be highly inefficient, but let me know about your experiences with it. In the long run Resolver aims to solve exactly this problem though, as we have customers who also want to use Numpy. Michael http://www.manning.com/foord
Mathew
Michael Foord wrote:
Hello all,
I've just posted the experimental code for accessing CPython extensions from IronPython. It uses the embedding wrapper from Python.NET so I thought I would let you know. :-)
Blog entry: http://www.voidspace.org.uk/python/weblog/arch_d7_2007_10_20.shtml#e862 Article: http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml
Despite some serious limitations it works! I have already had matplotlib with numpy and Tkinter working from IronPython.
We're evaluating to see if this should be the basis of our 'C Extensions from IronPython' project.
All the best,
Michael http://www.manning.com/foord
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
Michael Foord wrote:
Hey - well if someone uses it I might actually maintain it... :-)
For passing lots of data in and out it will probably be highly inefficient, but let me know about your experiences with it.
In the long run Resolver aims to solve exactly this problem though, as we have customers who also want to use Numpy.
We might be able to resolve the problem and make it more efficient. I'm not sure if it will actually work and my C+/.NET knowledge is too limited to implement it on my own. Python 2.x has something called buffer() (http://docs.python.org/api/abstract-buffer.html). It's designed for quick memory access of Python objects. IIRC numpy is supporting the buffer protocol, too. It *might* be possible to use the buffer protocol to exchange data between CPython and IronPython by using unsafe code. PythonDotNet uses unsafe code and direct access to memory all the time to make it efficient. I don't think it's possible to write unsafe and unmanaged code with IronPython but with C# one could write some nice and hacky pointer operations. Christian
Christian Heimes wrote:
Michael Foord wrote:
Hey - well if someone uses it I might actually maintain it... :-)
For passing lots of data in and out it will probably be highly inefficient, but let me know about your experiences with it.
In the long run Resolver aims to solve exactly this problem though, as we have customers who also want to use Numpy.
We might be able to resolve the problem and make it more efficient. I'm not sure if it will actually work and my C+/.NET knowledge is too limited to implement it on my own.
Python 2.x has something called buffer() (http://docs.python.org/api/abstract-buffer.html). It's designed for quick memory access of Python objects. IIRC numpy is supporting the buffer protocol, too. It *might* be possible to use the buffer protocol to exchange data between CPython and IronPython by using unsafe code. PythonDotNet uses unsafe code and direct access to memory all the time to make it efficient.
I don't think it's possible to write unsafe and unmanaged code with IronPython but with C# one could write some nice and hacky pointer operations.
This is very interesting and could be very useful - thanks. Whichever approach we take we will need to investigate this. Thanks Michael http://www.manning.com/foord
Christian
participants (4)
-
Brian Lloyd
-
Christian Heimes
-
Mathew Yeates
-
Michael Foord