[BangPypers] sort query

Anand Chitipothu anandology at gmail.com
Sat Oct 24 12:13:55 CEST 2009


On Sat, Oct 24, 2009 at 3:35 PM, Sidharth Kuruvila
<sidharth.kuruvila at gmail.com> wrote:
> Hi Anand.
>
>> Looks like Python dictionary implementation is doing something clever.
>> d.keys() returns the cached object if its refcount == 1 and returns a
>> new object if refcount > 1.
>>
>
> I don't think that's what's happening
>
>>>> id(d.keys())
> 535168
>>>> id(d.keys())
> 535168
>>>> l = [1,2,3,4]
>>>> id(d.keys())
> 542640
>
> It seems that when d.keys is called the second it's using the same
> memory as the previous call as that one was deleted. Creating a list
> displaces the memory.

Hmm.. I think you are right.

Anand


More information about the BangPypers mailing list