On 2-Apr-08, at 3:48 PM, Martin v. Löwis wrote: >> On Wed, Apr 2, 2008 at 5:08 PM, Mike Klaas <[EMAIL PROTECTED]> >> wrote: >>> ...and the majority of these cases would work fine with views (input >>> to sorted(), etc). >> >> Suppose "the majority" here means 36 of the 46 cases. > > What makes you suppose so. In the standard library of Python 2.5, I > could not find a single case where using views would cause silent > breakage: > - the majority of uses is in for loops or list comprehensions. > - of the remaining uses, the majority is with .sort(), which > would cause an exception, to be rewritten as sorted(foo.items()) > - of the then-remaining cases, the majority is immediately followed > by an iteration, with no intermediate changes to the dictionary. > - in some cases, the view is returned to the caller (i.e. outside > of the standard library); whether this would break anything would > depend on the application. > > In your code, how many (in absolute numbers) applications of .items() > would break when .items() becomes a view?
I assume you are asking Jason even though you attributed the quote to me. However, a cursory examination of the 46 non-'for' I quoted above results in a situation much like you describe: either silently working fine with view, or louding breaking where a list was expected. There are some that get passed out of functions which may fail silently but I don't have time to examine them in detail right now. -Mike _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com