On Mon, Nov 9, 2009 at 7:47 PM, Ognjen Bezanov <ogn...@mailshack.com> wrote: > Hello all, > > Say I have a python variable: > > a = "hello" > > Is it possible for me to get the physical address of that variable (i.e. > where it is in RAM)? > > I know that id(a) will give me it's memory address, but the address given > does not seem to correlate with the physical memory. Is this even possible? > > > Thank you! > > > Ognjen >
When you use Python, program in Python and not C. What do you need the memory location of a variable for? Python, like Java and .NET is a higher level language. You're not supposed to worry about things like the physical location in memory. There's probably some ugly hack using ctypes, or just writing the code in C but I don't know enough about Python's C API to know what it is. FWIW, even the id(x) == address of x is only an implementation detail of CPython. Other Python implementations don't use that scheme. > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list