[Python-checkins] r54883 - peps/trunk/pep-3119.txt

guido.van.rossum python-checkins at python.org
Fri Apr 20 05:29:56 CEST 2007


Author: guido.van.rossum
Date: Fri Apr 20 05:29:51 2007
New Revision: 54883

Modified:
   peps/trunk/pep-3119.txt
Log:
Turn XXX into open issues.  Fix append (was listed as add).
Respond to Brett's email.


Modified: peps/trunk/pep-3119.txt
==============================================================================
--- peps/trunk/pep-3119.txt	(original)
+++ peps/trunk/pep-3119.txt	Fri Apr 20 05:29:51 2007
@@ -116,8 +116,8 @@
 
 * An "ABC support framework" which defines a metaclass, a base class,
   a decorator, and some helpers that make it easy to define ABCs.
-  This will be added as a new library module named "abc", or (perhaps)
-  made built-in functionality.
+  This will be added as a new library module named "abc", or
+  (probably) made built-in functionality.
 
 * Specific ABCs for containers and iterators, to be added to the
   collections module.
@@ -166,11 +166,15 @@
 a class attribute named ``__abstractmethods__``.  Then the
 ``Abstract.__new__()`` method would raise an exception if any abstract
 methods exist on the class being instantiated.  For details see [2]_.
+(However, this would incur a significant cost upon each instantiation.
+A better approach would be to do most of the work in the metaclass.)
 
-**Open issue:** perhaps ``abstractmethod`` and
+**Open issue:** Probably ``abstractmethod`` and
 ``AbstractInstantiationError`` should become built-ins, ``Abstract``'s
 functionality should be subsumed by ``object``, and
 ``AbstractClass``'s functionality should be merged into ``type``.
+This would require a more efficient implementation of the
+instantiable-test sketched above.
 
 
 ABCs for Containers and Iterators
@@ -242,7 +246,11 @@
     The abstract ``__len__`` method returns 0.  **Invariant:** If a
     class ``C`` derives from ``Finite`` as well as from ``Iterable``,
     the invariant ``sum(1 for x in o) == len(o)`` should hold for any
-    instance ``o`` of ``C``.
+    instance ``o`` of ``C``.  **Open issue:** ``Finite`` may be a
+    confusing name.  Other alternatives already rejected: ``Lengthy``,
+    ``Sizeable`` (both too cute), ``Countable`` (the set of natural
+    numbers is a countable set in math).  We may just have to teach
+    people what we mean...
 
 ``Container``
     The base class for classes defining ``__contains__``.  The
@@ -315,7 +323,7 @@
     type in Python 2 are not supported, as these are mostly just
     aliases for ``__le__`` and ``__ge__``.
 
-    **Open Issues:** Should I spell out the invariants and method
+    **Open issues:** Should I spell out the invariants and method
     definitions?
 
 ``ComposableSet``
@@ -331,7 +339,7 @@
     should ensure that the results match the mathematical definition
     of set composition.
 
-    **Open Issues:** Should I spell out the invariants?  Should we
+    **Open issues:** Should I spell out the invariants?  Should we
     define an API for creating new instances (e.g. a class method or a
     fixed constructor signature)?  Should we just pick a concrete
     return type (e.g. ``set``)?  Should we add the ``copy`` method?
@@ -345,7 +353,7 @@
     as dictionary keys.  (A similar constraint exists on the hash
     values for different types of numbers and strings.)
 
-    **Open Issues:** Should I spell out the hash algorithm?  Should
+    **Open issues:** Should I spell out the hash algorithm?  Should
     there be another ABC that derives from Set and Hashable (but not
     from Composable)?
 
@@ -393,9 +401,6 @@
 
 The built-in type ``dict`` derives from ``MutableMapping``.
 
-XXX Do we need BasicMapping and IterableMapping?  Perhaps we should
-just start with Mapping.
-
 ``BasicMapping``
     A subclass of ``Container`` defining the following methods:
 
@@ -441,9 +446,18 @@
 ``MutableMapping``
     A subclass of ``Mapping`` that also implements some standard
     mutating methods.  At least ``__setitem__``, ``__delitem__``,
-    ``clear``, ``update``.  XXX Also pop, popitem, setdefault?
+    ``clear``, ``update``.
+
+**Open Issues:**
+
+* What about pop, popitem, setdefault?  (``MutableSequence`` does have
+  ``pop``.  Though it's not quite the same.)
+
+* Do we need BasicMapping and IterableMapping?  We should probably
+  just start with Mapping.
+
+* We should say something about mapping view types, too.
 
-XXX Should probably say something about mapping view types, too.
 
 Sequences
 '''''''''
@@ -465,9 +479,9 @@
     ``IndexError`` is raised.  The length should be equal to the
     number of values returned by the iterator.
 
-    XXX Other candidate methods, which can all have default concrete
-    implementations that only depend on ``__len__`` and
-    ``__getitem__`` with an integer argument: __reversed__, index,
+    **Open issues:** Other candidate methods, which can all have
+    default concrete implementations that only depend on ``__len__``
+    and ``__getitem__`` with an integer argument: __reversed__, index,
     count, __add__, __mul__, __eq__, __lt__, __le__.
 
 ``HashableSequence``
@@ -478,21 +492,23 @@
 ``MutableSequence``
     A subclass of ``Sequence`` adding some standard mutating methods.
     Abstract mutating methods: ``__setitem__`` (for integer indices as
-    well as slices), ``__delitem__`` (ditto), ``insert``, ``add``,
+    well as slices), ``__delitem__`` (ditto), ``insert``, ``append``,
     ``reverse``.  Concrete mutating methods: ``extend``, ``pop``,
     ``remove``.  Note: this does not define ``sort()`` -- that is only
     required to exist on genuine ``list`` instances.
 
-    XXX What about ``+=`` and ``*=``?
+    **Open issues:** What about ``+=`` and ``*=``?  (Including these
+    in the spec would clarify that they are *required* to be
+    implemented as in-place modifications.)
 
 
 ABCs for Numbers
 ----------------
 
-XXX define: Number, Complex, Real, Rational, Integer.  Do we have a
-use case for Cardinal (Integer >= 0)?  Do we need Indexable (converts
-to Integer using __index__)?  Or is that just subsumed into Integer
-and should we use __index__ only at the C level?
+**Open issues:** Define: Number, Complex, Real, Rational, Integer.  Do
+we have a use case for Cardinal (Integer >= 0)?  Do we need Index
+(converts to Integer using __index__)?  Or is that just subsumed into
+Integer and should we use __index__ only at the C level?
 
 
 Guidelines for Writing ABCs
@@ -511,7 +527,7 @@
 * Keep abstract classes small, one per use case instead of one per
   concept.
 
-* XXX What else?
+* What else?
 
 
 ABCs vs. Alternatives
@@ -603,7 +619,7 @@
   issues there don't have much in common with the issues for
   collection types.
 
-* XXX What else?
+* What else?
 
 
 References


More information about the Python-checkins mailing list