From: ara.t.howard@... Date: 2006-07-11T23:41:40+09:00 Subject: Re: Object IDs On Tue, 11 Jul 2006, Guillaume Marcais wrote: > > Le 11 juil. 06, � 10:10, Alex Young a �crit : > >> A couple of quick questions: >> >> a) Are object id's ever reused within the life of a Ruby process? > > I believe that Object#equal? compares ids if not overridden. > >> >> b) Are object id's unique across the whole Ruby process, or only within a >> given context? > > Unique across the process. if you wait long enough they can be recycled so i wouldn't say they are unique 'across' a process. that is to say ruby code which does this hash = Hash.new{|h, object_id| h[object_id] << 42} will stack info about two different objects if it runs long enough or is simply unlucky and only runs for a short time. in otherwords id = object.object_id # time value = ObjectSpace::_id2ref id may or may not retreive the same object and the error may or may not go unnoticed. in summary, i'd say that object_ids are unique in a given context, that context being an instant of time in a given process. as time progresses, even by a millisecond, the chances of objects being recycled increases. fyi. regards. -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama