save dictionary to a file without brackets.

Roman Vashkevich vashkevichrb at gmail.com
Thu Aug 9 18:02:00 EDT 2012


10.08.2012, в 1:47, Dave Angel написал(а):

> On 08/09/2012 05:34 PM, Roman Vashkevich wrote:
>> Actually, they are different.
>> Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred thousand entries, and you will feel the difference.
>> Dict uses hashing to get a value from the dict and this is why it's O(1).
> 
> Sure, that's why
> 
> for key in dict:
> 	print key[0], key[1], dict[key]
> 
> is probably slower than
> 
> for (edge1, edge2), cost in d.iteritems(): # or .items()
>  print edge1, edge2, cost
> 
> 
> So, the latter is both faster and easier to read.  Why are you arguing against it?
> 
> Also, please stop top-posting.  It's impolite here, and makes it much harder to figure out who is saying what, in what order.
> 
> 
> 
> -- 
> 
> DaveA
> 

I'm not arguing at all. Sorry if it sounded like I was arguing.
Thanks for notifying me of the way messages should be sent.

Roman


More information about the Python-list mailing list