how to get back an object from its id() value

Christian Heimes lists at cheimes.de
Wed Apr 8 14:03:31 EDT 2009


TP wrote:
> If "di" is reliable, it seems a good solution for my initial constraint
> which is the impossibility to store anything but strings in my data
> structure.

'di' is dangerous and not reliable. When the original object is freed,
then the memory address may be used by another Python object, point to
an invalid Python object or some random bytes. You can easily mess up or
seg fault the Python interpreter. 'di' is an evil debugging hack that
may proof useful as last resort.

Do *not* use anything like 'di' in production code.

Christian





More information about the Python-list mailing list