[Tutor] Working with memory in Python?

Jeff Shannon jeff@ccvcorp.com
Thu Dec 5 18:16:15 2002


Jmllr891@cs.com wrote:

> I know that most of the time it requires a low level language (such as 
> C) to work with memory, but is it at all possible to work with memory 
> with Python?
>
> An example of what I am trying to find out would be finding the 
> address of a particular file on a system and then being able to 
> modify/overwrite the memory that that particular file is using.


In practice, no, that sort of thing is not possible in Python.  (There 
may or may not be advanced black-magic hacks that would allow you to 
accomplish that, but it would be messy, and if you *really* need to do 
such a thing, you'd be better off doing it in C.)

However, for most practical applications of such tricks, it's possible 
to find some alternative method of acheiving the same long-range goal. 
 Most such goals can be accomplished without direct hardware access. 
 What exactly is the purpose of modifying the memory image of a file, as 
opposed to simply re-reading a modified file from disk?

Jeff Shannon
Technician/Programmer
Credit International