[IronPython] ctypes for IronPython (preliminary)
fuzzyman at voidspace.org.uk
Thu Jun 8 10:52:20 CEST 2006
Sanghyeon Seo wrote:
> ctypes is a popular CPython extension planned for inclusion in Python
> 2.5. It is a foreign function interface library.
> Homepage: http://starship.python.net/crew/theller/ctypes/
> Documentation: http://docs.python.org/dev/lib/module-ctypes.html
> I would like to announce a preliminary implementation of ctypes for
> IronPython using .NET's P/Invoke machinery.
> Code is here: http://sparcs.kaist.ac.kr/~tinuviel/fepy/lib/ctypes.py
> Example is here: http://sparcs.kaist.ac.kr/~tinuviel/fepy/example/ctypes_test.py
> The example can be run on IronPython as well as on CPython.
Wow. Given that one of the google SoC projects is to implement some of
the Python C extensions for PyPy using ctypes, this opens new possibilities.
> What's missing:
> * Many primitive types
> * .value on primitive types
> * Buffers and .raw
> * Pointer and .contents
> * Reference
> * Array
> * Structure and union and .offset
> * Recursive type
> * Callback
> * External value
> * Windows goodies
> In short, everything except those needed to demo anything interesting.
> :-) But you can do this now:
> IronPython 1.0.60523 (Beta) on .NET 2.0.50727.42
> Copyright (c) Microsoft Corporation. All rights reserved.
>>>> from ctypes import *
>>>> print cdll.msvcrt.strlen('hello')
> Seo Sanghyeon
> users mailing list
> users at lists.ironpython.com
More information about the Ironpython-users