471,334 Members | 2,679 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,334 software developers and data experts.

Data [shared] between python and c program

14
Hey

Im having a problem with data communication between a python program and a c program.

The c program calculates the data, so it a kind of a solver.
Data variables should be chanced in real time from the python program.

A solution could be writing to shared memory. But how can i write an array to shared memory?
Or is there anybody there have another idea`?
Jun 4 '07 #1
3 3245
bartonc
6,596 Expert 4TB
Hey

Im having a problem with data communication between a python program and a c program.

The c program calculates the data, so it a kind of a solver.
Data variables should be chanced in real time from the python program.

A solution could be writing to shared memory. But how can i write an array to shared memory?
Or is there anybody there have another idea`?
Because most data objects in memory are relocatable, it's kind of scary to implement memory shares. The C part of the system would need to allocate the memory and make sure that it doesn't get relocated and return it to python as a PyObject.

The really tricky part would be trying to syncronize the solver with the changes to the data.

I'm going to ponder on this problem. It is doable, but your model seem a bit out of whack.

For a quick implementation that didn't need super high performance, I'd use a DB and write SQL queries on both sides of the problem space.
Jun 4 '07 #2
Motoma
3,237 Expert 2GB
Hey

Im having a problem with data communication between a python program and a c program.

The c program calculates the data, so it a kind of a solver.
Data variables should be chanced in real time from the python program.

A solution could be writing to shared memory. But how can i write an array to shared memory?
Or is there anybody there have another idea`?
Have one of the programs call the other?
Jun 4 '07 #3
bartonc
6,596 Expert 4TB
Have one of the programs call the other?
Yep. That's the normal way to do it. I like to call DLL functions from Python. But if the process of "solving" is a long running operation, then you want a thread that's already running (or started by the ready-state of the data) which has some way of signaling that it has completed its task (hence the shared memory idea).
Jun 4 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by socket | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.