Is it possible to get the Physical memory address of a variable in python?
Ognjen Bezanov
Ognjen at mailshack.com
Tue Nov 10 06:32:46 EST 2009
Hey,
Thanks for all the responses guys. In hindsight I probably should have
explained why on earth I'd need the physical address from an interpreted
language.
I'm trying to see if there is any way I can make Python share data
between two hosts using DMA transfers over a firewire connection, so
avoiding the need for another layer on top such as IPv4 + Python sockets.
Thanks to some old python bindings which I updated to python 2.6, I can
read any write to the RAM of any firewire connected host within python.
Because it uses DMA (the cpu is not involved in this at all), I can only
specify a physical address within the 4GB ram limit to read from and
write to.
Now what I've done so far is on the remote host I run python and set a
variable as so:
a = "foo"
print a
'foo'
Then on the local host I run a python script that scans the entire RAM
looking for the string "foo", and replaces it with the string "oof". I
have had success with this method. Once it's done and I do "print a" on
the remote host, I get "oof" as the variable value, so in theory it can
work.
Problem is that it's slow. Scanning 3GB of RAM every time you want to do
this is not a good method. I thought that if I could get python to
return the physical address of where the value of a variable is, then I
can just jump to that address and write the data.
From what I've been told so far, it's not possible to do this without
some OS-specific (Linux in this case) syscall. Is this correct?
Thanks!
Ognjen
More information about the Python-list
mailing list