weakrefs, threads,, and object ids

Aahz aahz at pythoncraft.com
Mon Jun 15 17:47:45 CEST 2009


In article <84397edd-4830-4c90-9fb6-f72c74028f6e at i28g2000prd.googlegroups.com>,
Jeremy  <jeremy.r.fishman at gmail.com> wrote:
>
>While guaranteed unique for simultaneously existing objects, how often
>will an object assume an ID previously held by former object?  Given
>that the ID is a memory address in Python's heap, I assume the answer
>is either not often, or very often.

Very often:

Python 2.4 (#1, Jan 17 2005, 14:59:14) 
[GCC 3.3.3 (NetBSD nb3 20040520)] on netbsd2
Type "help", "copyright", "credits" or "license" for more information.
>>> x = id(object())
>>> y = id(object())
>>> x == y
True

Sorry, can't help you with your other questions; I'm not familiar with
weakrefs.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer



More information about the Python-list mailing list