Author: raymond.hettinger
Date: Sat Feb 9 00:46:23 2008
New Revision: 60676
Modified:
python/branches/py3k/Doc/library/collections.rst
Log:
Smalls improvement to example in the docs for collections ABCs.
Modified: python/branches/py3k/Doc/library/collections.rst
==============================================================================
--- python/branches/py3k/Doc/library/collections.rst (original)
+++ python/branches/py3k/Doc/library/collections.rst Sat Feb 9 00:46:23 2008
@@ -43,10 +43,8 @@
:class:`Iterable`,
and :class:`Sized`, and in addition
defines ``__getitem__()``, ``get()``,
- ``__contains__()``, ``__len__()``,
``__eq__()``, ``__ne__()``,
- ``__iter__()``, ``keys()``,
- ``items()``, and ``values()``
+ ``keys()``, ``items()``, and
``values()``
:class:`collections.MutableMapping` Derived from :class:`Mapping`
:class:`collections.Sequence` Derived from :class:`Container`,
:class:`Iterable`, and :class:`Sized`,
@@ -83,9 +81,13 @@
:meth:`isdisjoint` ::
class ListBasedSet(collections.Set):
- 'Alternate set implementation favoring space over speed'
+ ''' Alternate set implementation favoring space over speed
+ and not requiring the set elements to be hashable. '''
def __init__(self, iterable):
- self.elements = list(set(iterable))
+ self.elements = lst = []
+ for value in iterable:
+ if value not in lst:
+ lst.append(value)
def __iter__(self):
return iter(self.elements)
def __contains__(self, value):
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins