PyInline Released: Put C source code directly "inline" with your Python!

Alexey Goldin Alexey.Goldin at jpl.nasa.gov
Fri Aug 31 13:54:08 EDT 2001


ksimpson at ttul.org (Ken Simpson) writes:

> The PyInline module allows you to put source code from other
> programming languages directly "inline" in a Python script or
> module. The code is automatically compiled as needed and then loaded
> for immediate access from Python.


This is insanely cool and produced some dropped jaws among some
IDL and Matlab fans around here.

The question is, what I am doing wrong here (or is it allowed at all)?

############ simple test code ##################
from PyInline import C

x = C.Builder(code="""
PyObject* test_pyobj(PyObject *self, PyObject *args) {
  int t;
  if (!PyArg_ParseTuple(args, "i", &t))
        return NULL;
  return Py_BuildValue("i", t*2) ;
}

""")

# 2. Build the module. build() returns a new module object.
m = x.build()

# 3. Call a method in the newly built module.
print m.test_pyobj(3)
print m.test_pyobj("ha") # should bomb

#########################################################

Running the code:

Traceback (most recent call last):
  File "test_inline.py", line 21, in ?
    print m.test_pyobj(3)
SystemError: new style getargs format but argument is not a tuple

Version:


Python 2.1.1 (#1, Aug  1 2001, 23:36:34) 
[GCC 2.95.4 20010319 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
import readline # dynamically loaded from /usr/lib/python2.1/lib-dynload/readline.so


Thanks!



BTW, may I look forward to C++ support? blitz
(www.oonumerics.org/blitz/ )?



More information about the Python-list mailing list