[Patches] [ python-Patches-1397711 ] Fix dict and set docs, re: immutability
SourceForge.net
noreply at sourceforge.net
Fri Jan 13 23:09:08 CET 2006
Patches item #1397711, was opened at 2006-01-05 07:28
Message generated for change (Comment added) made by jimjjewett
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1397711&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Collin Winter (collinwinter)
Assigned to: Raymond Hettinger (rhettinger)
Summary: Fix dict and set docs, re: immutability
Initial Comment:
This patch resolves bug #1368768.
As mentioned in the bug description, the documentation
for sets and dicts incorrectly reports that set members
and dict keys must be immutable. This patch corrects
this, changing references to immutability to
hashability and inserting footnotes describing what is
meant by "hashable".
The patch is a diff against Doc/lib/libstdtypes.tex
from SVN revision 41926.
----------------------------------------------------------------------
Comment By: Jim Jewett (jimjjewett)
Date: 2006-01-13 17:09
Message:
Logged In: YES
user_id=764593
Definately an improvement, but it still may not be quite
right in the footnote. You don't have to define a __hash__
method; you just need to avoid redefining it (or __eq__) to
something that doesn't work.
Here is another stab
Hashable objects must define or inherit proper
\method{__hash__} and \method{__eq__} methods. Most objects
do, but some mutable types -- including lists -- redefine
equality in such a way that the hash code would not be
stable. Instead, their hash functions return -1 to indicate
that the object should not be used as a dict key or set
member.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1397711&group_id=5470
More information about the Patches
mailing list