[Python-checkins] python/dist/src/Doc/lib libuserdict.tex,1.22,1.23

rhettinger@projects.sourceforge.net rhettinger@projects.sourceforge.net
Sun, 17 Nov 2002 20:34:12 -0800


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv23016/Doc/lib

Modified Files:
	libuserdict.tex 
Log Message:
Improve DictMixin.
Replaced docstring with comments.  Prevents subclass contamination.
Added the missing __cmp__() method and a test for __cmp__().
Used try/except style in preference to has_key() followed by a look-up.
Used iteritem() where possible to save creating a long key list and
   to save redundant lookups.
Expanded .update() to look for the most helpful methods first and gradually
   work down to a mininum expected interface.
Expanded documentation to be more clear on how to use the class.



Index: libuserdict.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuserdict.tex,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** libuserdict.tex	15 Nov 2002 06:46:13 -0000	1.22
--- libuserdict.tex	18 Nov 2002 04:34:10 -0000	1.23
***************
*** 44,60 ****
  \begin{classdesc}{DictMixin}{}
  Mixin defining all dictionary methods for classes that already have
! a minimum dictionary interface including\method{__getitem__},
! \method{__setitem__}, \method{__delitem__}, and \method{keys}.
  
  This mixin should be used as a superclass.  Adding each of the
  above methods adds progressively more functionality.  For instance,
! the absence of \method{__delitem__} precludes only \method{pop}
! and \method{popitem}.
  
! While the four methods listed above are sufficient to support the
! entire dictionary interface, progessively more efficiency comes
! with defining \method{__contains__}, \method{__iter__}, and
! \method{iteritems}.
  
  \end{classdesc}
  
--- 44,61 ----
  \begin{classdesc}{DictMixin}{}
  Mixin defining all dictionary methods for classes that already have
! a minimum dictionary interface including \method{__getitem__()},
! \method{__setitem__()}, \method{__delitem__()}, and \method{keys()}.
  
  This mixin should be used as a superclass.  Adding each of the
  above methods adds progressively more functionality.  For instance,
! defining all but \method{__delitem__} will preclude only \method{pop}
! and \method{popitem} from the full interface.
  
! In addition to the four base methods, progessively more efficiency
! comes with defining \method{__contains__()}, \method{__iter__()}, and
! \method{iteritems()}.
  
+ Since the mixin has no knowledge of the subclass constructor, it
+ does not define \method{__init__()} or \method{copy()}.
  \end{classdesc}