Native class methods
Chris Mellon
arkanes at gmail.com
Tue Oct 9 11:28:55 EDT 2007
On 09 Oct 2007 17:20:09 +0200, Stefan Arentz <stefan.arentz at gmail.com> wrote:
>
> Is there an easy way to implement a specific method of a Python class
> in C? Like a native method in Java? I would really like to do the
> majority of my class code in Python and just do one or two methods
> in C.
>
> S.
>
Weave kinda does this - you can use it write inline C code, which it
extracts and compiles for you. (http://scipy.org/Weave)
You might also want to look at Pyrex and/or Cython, which let you
write in a Python-like language that is compiled to C.
(http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ and
http://cython.org).
Depending on what you want to do in C, just writing it as a normal
shared library and calling it with ctypes might also be an effective
solution. (in the standard library, as of 2.5)
More information about the Python-list
mailing list