[BangPypers] sort query
Sidharth Kuruvila
sidharth.kuruvila at gmail.com
Sat Oct 24 12:05:09 CEST 2009
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.
Regards,
Sidharth
More information about the BangPypers
mailing list