Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28746

Re: set and dict iteration

Date 2012-09-08 22:22 +0100
From MRAB <python@mrabarnett.plus.com>
Subject Re: set and dict iteration
References (5 earlier) <fe95c29c-2289-4e9c-870e-e3c475f13459@googlegroups.com> <mailman.3435.1345240665.4697.python-list@python.org> <d4708687-2925-421a-b755-969d6dac731a@googlegroups.com> <mailman.3476.1345328046.4697.python-list@python.org> <k2g8fg$fop$1@r03.glglgl.gl>
Newsgroups comp.lang.python
Message-ID <mailman.392.1347139563.27098.python-list@python.org> (permalink)

Show all headers | View raw


On 08/09/2012 21:06, 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.
>
> Or would that be detected via the list?
>
The quote was:

'''
...The tuple type does not implement a tp_clear function, because it’s 
possible to prove that no reference cycle can be composed entirely of 
tuples.
'''

Note: "composed entirely of tuples".

Or, in general, composed entirely of immutables.

Lists are not immutable, therefore the proof does not apply.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: set and dict iteration Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-09-08 22:06 +0200
  Re: set and dict iteration Hans Mulder <hansmu@xs4all.nl> - 2012-09-08 23:18 +0200
  Re: set and dict iteration MRAB <python@mrabarnett.plus.com> - 2012-09-08 22:22 +0100

csiph-web