473,371 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,371 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 3370
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

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

Similar topics

5
by: Claudio Grondi | last post by:
Background information: --------------------------------- in order to monitor mainboard sensory data as fan speeds, temperatures, applications like SpeedFan http://www.almico.com/speedfan.php or...
3
by: sdhyok | last post by:
Recently, I installed many shared libraries to run a program written in Python. Now, I am in the situation to run the same program but on several different machines with the same Linux OS. To...
2
by: socket | last post by:
Hey, I need to make two programs I wrote to communicate with each other, but what's the best way to implement it? Both programs will be running on the same machine. I don't want to open sockets...
2
by: Al | last post by:
Hello, I want my python application to communicate with an legacy C program which read/write data in a shared memory (Unix Sys V IPC). It seems that there are no official shm nor sysV ipc...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.