Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > These results make more sense. However, I am still puzzled : > > > > 1. why would d.keys()/d.values() only return one list element ? Why > > isn't it a list of 1M element of either the keys or values but items() > > is ? > > "keys" returns a single list object which contains references to existing > key objects. "items" has to create one million new pair objects (which > in turn hold references to existing key and value objects). > Ah, that is clearer now. So keys()/items() create a list of 1M reference(object identity?) to existing objects, items() also contains 1 M reference, but to a newly created 1M tuples.
How about the other puzzle of whether seperate keys()/values() pair have real performance gain in real use ? -- http://mail.python.org/mailman/listinfo/python-list