[Python-checkins] CVS: python/dist/src/Doc/ref ref5.tex,1.49,1.50
Tim Peters
tim_one@users.sourceforge.net
2001年10月01日 13:22:47 -0700
Update of /cvsroot/python/python/dist/src/Doc/ref
In directory usw-pr-cvs1:/tmp/cvs-serv31378/python/Doc/ref
Modified Files:
ref5.tex
Log Message:
The description of dictionary comparison was out of date. Rather than
try to explain the complex general scheme we actually use now, I decided
to spell out only what equality means (which is easy to explain and
intuitive), leaving the other outcomes unspecified beyond consistency.
Index: ref5.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** ref5.tex 2001年07月06日 22:49:53 1.49
--- ref5.tex 2001年10月01日 20:22:45 1.50
***************
*** 192,199 ****
order. When a list comprehension is supplied, it consists of a
single expression followed by at least one \keyword{for} clause and zero or
! more \keyword{for} or \keyword{if} clauses. In this
case, the elements of the new list are those that would be produced
by considering each of the \keyword{for} or \keyword{if} clauses a block,
! nesting from
left to right, and evaluating the expression to produce a list element
each time the innermost block is reached.
--- 192,199 ----
order. When a list comprehension is supplied, it consists of a
single expression followed by at least one \keyword{for} clause and zero or
! more \keyword{for} or \keyword{if} clauses. In this
case, the elements of the new list are those that would be produced
by considering each of the \keyword{for} or \keyword{if} clauses a block,
! nesting from
left to right, and evaluating the expression to produce a list element
each time the innermost block is reached.
***************
*** 816,826 ****
\item
! Mappings (dictionaries) are compared through lexicographic
! comparison of their sorted (key, value) lists.\footnote{
! This is expensive since it requires sorting the keys first,
! but it is about the only sensible definition. An earlier version of
! Python compared dictionaries by identity only, but this caused
! surprises because people expected to be able to test a dictionary for
! emptiness by comparing it to \code{\{\}}.}
\item
--- 816,829 ----
\item
! Mappings (dictionaries) compare equal if and only if their sorted
! (key, value) lists compare equal.\footnote{The implementation computes
! this efficiently, without constructing lists or sorting.}
! Outcomes other than equality are resolved consistently, but are not
! otherwise defined.\footnote{Earlier versions of Python used\
! lexicographic comparison of the sorted (key, value) lists, but this
! was very expensive for the common case of comparing for equality. An
! even earlier version of Python compared dictionaries by identity only,
! but this caused surprises because people expected to be able to test
! a dictionary for emptiness by comparing it to \code{\{\}}.}
\item