On 8/09/12 22:06:08, Thomas Rachel wrote: > Am 19.08.2012 00:14 schrieb MRAB: > >>> Can someone who is more familiar with the cycle detector and cycle >>> breaker, help prove or disprove the above? >>> >> In simple terms, when you create an immutable object it can contain >> only references to pre-existing objects, but in order to create a cycle >> you need to make an object refer to another which is created later, so >> it's not possible to create a cycle out of immutable objects. > > Yes, but if I add a list in-between, I can create a refcycle: > > a = [] > b = (a,) > a.append(b) > > So b is a tuple consisting of one list which in turn contains b. > > It is not a direct cycle, but an indirect one.
It's a cycle and it contains an immutable object, but it's not a cycle consisting of immutable objects only. As MRAB was arguing: it is not possbible to create a cycle consisting of immutable objects only (unless you do unspeakable things at the C level). -- HansM -- http://mail.python.org/mailman/listinfo/python-list