How to get the actual address of a object

mujunshan at gmail.com mujunshan at gmail.com
Fri Oct 24 06:58:09 CEST 2008


On 10月24日, 下午12时51分, mujuns... at gmail.com wrote:
> Hi,I have a strange idea:is there any way to get  memory address of a
> object.
>
>       For example:
>
>                  i = 10
>
>                  addr = get_address(i)
>     address will be assigned a integer which is pointer of object
> i,then I want to recast addr into another integer:
>
>                  j = cast(addr,<type int>)
>
> I think it is easy to get it by modifying source code of  python,but I
> would like to know if there was an existing one.
>
> many thanks

maybe id(x) can get it ,but how to cast it back into a object



More information about the Python-list mailing list