- A c++ program receives a 2D-matrix from python as input and gives a
2D-matrix as output back to python.
pyogre uses swig
ogre is a 3d realtime rendering engine written in c++ so there are
many matrix manipulation there and also pyogre does not modify the
original code
cgkit is a computer
On 14 Mar 2007 02:38:32 -0700, Szabolcs Nagy [EMAIL PROTECTED] wrote:
- A c++ program receives a 2D-matrix from python as input and gives a
2D-matrix as output back to python.
pyogre uses swig
Well, pyogre has few problems with maintenance, and new bindings to
Ogre engine was
created using
Well, pyogre has few problems with maintenance, and new bindings to
Ogre engine was
created using Boost.Python( http://www.ogre3d.org/wiki/index.php/PyOgre )
oh
last time i played with pyogre they made a transition from boost to
swig :)
so they are back again at boost
(the problem with boost
Check out this example from NumPy. This would be the way sanctioned by
the scipy community, as you benefit from a large library of matrix
routines that you can use to prepare/postprocess the data.
http://www.scipy.org/Cookbook/SWIG_and_NumPy
--
En Wed, 14 Mar 2007 01:55:55 -0300, Frank [EMAIL PROTECTED] escribió:
is there anyone here that calls C++ programs from python via swig? It
I suggest you read the responses to your previous question; also search
the list archives for this month.
--
Gabriel Genellina
--
On Mar 14, 1:42 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
En Wed, 14 Mar 2007 01:55:55 -0300, Frank [EMAIL PROTECTED] escribió:
is there anyone here that calls C++ programs from python via swig? It
I suggest you read the responses to your previous question; also search
the list
Hi,
is there anyone here that calls C++ programs from python via swig? It
seems that there are a lot of different ways to do that. For me it
would be important that the original c++ code (which is available)
does not need to be changed and the whole compilation process (swig -
python
On 13 Mar 2007 21:55:55 -0700, Frank [EMAIL PROTECTED] wrote:
Hi,
is there anyone here that calls C++ programs from python via swig? It
seems that there are a lot of different ways to do that. For me it
would be important that the original c++ code (which is available)
does not need to be
Hi,
Can anyone give me some idea as to what this error means?
ImportError: dynamic module does not define init function
I am new at this and there is still a lot to learn.
Any help is appreciated,
/Sheldon
--
http://mail.python.org/mailman/listinfo/python-list
Sheldon wrote:
Can anyone give me some idea as to what this error means?
ImportError: dynamic module does not define init function
I am new at this and there is still a lot to learn.
Any help is appreciated,
Take a look at the documentation for creating extension modules,
especially
Farshid Lashkari skrev:
Sheldon wrote:
Can anyone give me some idea as to what this error means?
ImportError: dynamic module does not define init function
I am new at this and there is still a lot to learn.
Any help is appreciated,
Take a look at the documentation for creating
Sheldon wrote:
This function is there and is called init_mymodule() but I have other
functions that are not static.
Is the module's name _mymodule? Or is it mymodule?
--
Robert Kern
I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own
Robert Kern skrev:
Sheldon wrote:
This function is there and is called init_mymodule() but I have other
functions that are not static.
Is the module's name _mymodule? Or is it mymodule?
--
Robert Kern
I have come to believe that the whole world is an enigma, a harmless enigma
that
At Tuesday 7/11/2006 17:10, Sheldon wrote:
Take a look at the documentation for creating extension modules,
especially the following page:
http://docs.python.org/ext/methodTable.html
The initialization function must be named initname(), where name is the
name of the module, and should be
At Tuesday 7/11/2006 17:27, Sheldon wrote:
Here is the file/module name: _msgpps_functions.c
Here is the initfunction:
PyMODINIT_FUNC init_msgpps_functions(void) {
PyObject* m;
m=Py_InitModule(_msgpps_functions,_msgpps_functionsMethods);
ErrorObject =
Hi,
For a module called foo.c the initialization function must be called
initfoo (*not* init_foo)
Ok, I fixed this part. Thanks
And what are those non-static functions used for? The *only* purpose
of your module should be to provide the Python bindings...
I wrote the C module to do some
Gabriel Genellina skrev:
At Tuesday 7/11/2006 17:27, Sheldon wrote:
Here is the file/module name: _msgpps_functions.c
Here is the initfunction:
PyMODINIT_FUNC init_msgpps_functions(void) {
PyObject* m;
m=Py_InitModule(_msgpps_functions,_msgpps_functionsMethods);
ErrorObject =
At Tuesday 7/11/2006 17:43, Sheldon wrote:
And what are those non-static functions used for? The *only* purpose
of your module should be to provide the Python bindings...
I wrote the C module to do some number crunching. Now I just need to
connect it to my python program. Should the
is a
big help.
So, I'm looking for a C++ wrapper generator, so that I can
write a class in Python, and then have a .h and .cpp generated
that will give me a corresponding C++ class.
Of course, the usual restrictions apply: no dynamically
added methods, accessing all instance data via getters
, and the comprehensive Python library is a
big help.
So, I'm looking for a C++ wrapper generator, so that I can
write a class in Python, and then have a .h and .cpp generated
that will give me a corresponding C++ class.
Of course, the usual restrictions apply: no dynamically
added methods, accessing
Shi, Jue wrote:
Hello, Gurus,
I have a question on wrapping C function in Python.
My C code is like this:
typedef void (WINAPI *myCallBack) (unsigned int myarg1, unsigned int myarg2)
bool myfunc(myCallBack callfunc)
Now I want to call myfunc in Python, what should I do?
I replied to
Hello, Gurus,
I have a question on wrapping C function in Python.
My C code is like this:
typedef void (WINAPI *myCallBack) (unsigned int myarg1, unsigned int myarg2)
bool myfunc(myCallBack callfunc)
Now I want to call myfunc in Python, what should I do?
Thanks,
Stone
--
In article [EMAIL PROTECTED],
Java and Swing [EMAIL PROTECTED] wrote:
one more update...
if I remove PyMem_Free and free(...) ...so no memory clean up...I can
still only call doStuff 4 times, the 5th attemp crashes Python.
Java and Swing wrote:
update:
if I use C's free(result),
Jeremy Moles wrote:
Probably what you want to do though is just keep the tuple as is and
iterate over it using the PySequence_* protocol:
http://docs.python.org/api/sequence.html
I did post a complete and tested example a few days ago, which contained
code that showed how to do this. a
Fredrik...I forgot about that...wish Google Groups had a way to quickly
find the topics a user posts.
anyhow, for receiving an object from python..is it
ok = PyArg_ParseTuple(args, sO, x, y);
...is it sO or s0 is it O (as in the letter) or 0 (as in the
number)? I would think O the
Fredrik,
...I tried using your code...
static long *get_long_array(PyObject *data, int *data_size) {
int i, size;
long* out;
PyObject* seq;
seq = PySequence_Fast(data, expected a sequence);
if (!seq)
return NULL;
size = PySequence_Size(seq);
if (size 0)
I got it. I had get_long_array placed after the method that was
calling it..
i.e.
void doStuf(...) {
x = get_long_array(...);
}
static long *get_long_array(PyObject *data, int *data_size) {
...
}
...I put get_long_array before it in my code..and its fine.
Thanks
Java and Swing wrote:
I have been posting lately about writing a C wrapper so Python can
access my C functions.
In my wrapper function I have something like...
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
PyObject *data;
char *result;
long *d;
PyArg_ParseTuple(args, O:wrap_doStuff
. This leaves the caller with the responsibility
to call Py_DECREF() when they are done with the result; this soon
becomes second nature.
URL: http://www.python.org/doc/api/refcounts.html
So does that mean before my C wrapper function exits, or returns I
should Py_DECREF any PyObject's I have? For example
Java and Swing wrote:
and I get this error..
C:\project\myapp.c(549) : error C2040: 'get_long_array' : 'long
*(struct _object *,int *)' differs in levels of indirection from 'int
()'
so what's on line 549 in myapp.c?
what other warnings did you get from the compiler?
do you have other
Java and Swing wrote:
anyhow, for receiving an object from python..is it
ok = PyArg_ParseTuple(args, sO, x, y);
...is it sO or s0 is it O (as in the letter) or 0 (as in the
number)? I would think O the letter..but it looks like a zero.
eh? if you're not sure, what keeps you from
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
// this will store the result in a Python object
PyObject *finalResult;
// get arguments from Python
char *result = 0;
char *in= 0;
char *aString = 0;
char *bString = 0;
update:
if I use C's free(result), free(a) free(b) instead of PyMem_Free...I
only get one successfuly use/call of doStuff.
i.e.
// this works
doStuff(...)
// python crashes here
doStuff(...)
Java and Swing wrote:
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
// this
one more update...
if I remove PyMem_Free and free(...) ...so no memory clean up...I can
still only call doStuff 4 times, the 5th attemp crashes Python.
Java and Swing wrote:
update:
if I use C's free(result), free(a) free(b) instead of PyMem_Free...I
only get one successfuly use/call of
Op 2005-10-12, Java and Swing schreef [EMAIL PROTECTED]:
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
// this will store the result in a Python object
PyObject *finalResult;
// get arguments from Python
char *result = 0;
char *in= 0;
Antoon,
I just saw that to. I updated the code like so...
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
// this will store the result in a Python object
PyObject *finalResult;
// get arguments from Python
char *result = 0;
char *in=
Antoon,
I just saw that to. I updated the code like so...
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
// this will store the result in a Python object
PyObject *finalResult;
// get arguments from Python
char *result = 0;
char *in=
Sorry about the double post...
anyhow, after putting in debug statements I found that it was crashing
when it called, free(result)so I removed the free(result).
now it crashes when it gets to, b = GetVal(bString, count(bString,
,));
..any ideas?
Java and Swing wrote:
Antoon,
I just
this is crashing when calling from Python via C
wrapper?
Java and Swing wrote:
Sorry about the double post...
anyhow, after putting in debug statements I found that it was crashing
when it called, free(result)so I removed the free(result).
now it crashes when it gets to, b = GetVal(bString
Java and Swing [EMAIL PROTECTED] writes:
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
[...]
char *aString = 0;
char *bString = 0;
[...]
int ok = PyArg_ParseTuple(args, sss, in, aString, bString);
[...]
free(aString);
free(bString);
aString
thanks for the tip, however even when I do not free aString or bString,
i'm still crashing at the malloc in the c function, not the wrapper.
Bernhard Herzog wrote:
Java and Swing [EMAIL PROTECTED] writes:
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
[...]
char
Java and Swing [EMAIL PROTECTED] writes:
thanks for the tip, however even when I do not free aString or bString,
i'm still crashing at the malloc in the c function, not the wrapper.
Do you have any more places where you use free incorrectly? In my
experience, calling free with invalid values
As far as my C Wrapper functions are concerned...I no longer have the
need for free(...). I do use PyMem_Free, for structures I allocated by
using PyMem_New(...).
In my C code I do have things such as...
char *foo(const char *in) {
char *tmp;
tmp = (char *) malloc((strlen(in) * sizeof
Java and Swing [EMAIL PROTECTED] writes:
char *foo(const char *in) {
char *tmp;
tmp = (char *) malloc((strlen(in) * sizeof(char)) + 1);
strcpy(tmp, in);
...
...
free(tmp);
return someValue;
}
Is that appropriate? I was under the impression that when you
Bernhard Herzog wrote:
Java and Swing [EMAIL PROTECTED] writes:
char *foo(const char *in) {
char *tmp;
tmp = (char *) malloc((strlen(in) * sizeof(char)) + 1);
strcpy(tmp, in);
...
...
free(tmp);
return someValue;
}
Is that appropriate? I was
I have a C function which takes an array of long values..
I understand that I can pass a tuple to a C wrapper function and in the
C wrapper function have..
int ok = PyArg_ParseTuple(args, s(ll), a, b, c);
..that's great if my tuple only contained two longs..but what if it
contained 50
would I
On Wed, 2005-10-12 at 13:06 -0700, Java and Swing wrote:
I have a C function which takes an array of long values..
I understand that I can pass a tuple to a C wrapper function and in the
C wrapper function have..
int ok = PyArg_ParseTuple(args, s(ll), a, b, c);
..that's great if my tuple
47 matches
Mail list logo