Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8db45f94
Commit
8db45f94
authored
Apr 10, 2005
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF bug #1179957: Missing def'n of equality for set elements
parent
1b2a5cbc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
Doc/lib/libsets.tex
Doc/lib/libsets.tex
+4
-1
Doc/lib/libstdtypes.tex
Doc/lib/libstdtypes.tex
+3
-0
No files found.
Doc/lib/libsets.tex
View file @
8db45f94
...
@@ -30,7 +30,10 @@ method but omits methods which alter the contents of the set. Both
...
@@ -30,7 +30,10 @@ method but omits methods which alter the contents of the set. Both
abstract class useful for determining whether something is a set:
abstract class useful for determining whether something is a set:
\code
{
isinstance(
\var
{
obj
}
, BaseSet)
}
.
\code
{
isinstance(
\var
{
obj
}
, BaseSet)
}
.
The set classes are implemented using dictionaries. As a result, sets
The set classes are implemented using dictionaries. Accordingly, the
requirements for set elements are the same as those for dictionary keys;
namely, that the element defines both
\method
{__
eq
__}
and
\method
{__
hash
__}
.
As a result, sets
cannot contain mutable elements such as lists or dictionaries.
cannot contain mutable elements such as lists or dictionaries.
However, they can contain immutable collections such as tuples or
However, they can contain immutable collections such as tuples or
instances of
\class
{
ImmutableSet
}
. For convenience in implementing
instances of
\class
{
ImmutableSet
}
. For convenience in implementing
...
...
Doc/lib/libstdtypes.tex
View file @
8db45f94
...
@@ -1220,6 +1220,9 @@ Accordingly, sets do not implement the \method{__cmp__} method.
...
@@ -1220,6 +1220,9 @@ Accordingly, sets do not implement the \method{__cmp__} method.
Since sets only define partial ordering (subset relationships), the output
Since sets only define partial ordering (subset relationships), the output
of the
\method
{
list.sort()
}
method is undefined for lists of sets.
of the
\method
{
list.sort()
}
method is undefined for lists of sets.
Set elements are like dictionary keys; they need to define both
\method
{__
hash
__}
and
\method
{__
eq
__}
methods.
Binary operations that mix
\class
{
set
}
instances with
\class
{
frozenset
}
Binary operations that mix
\class
{
set
}
instances with
\class
{
frozenset
}
return the type of the first operand. For example:
return the type of the first operand. For example:
\samp
{
frozenset('ab') | set('bc')
}
returns an instance of
\class
{
frozenset
}
.
\samp
{
frozenset('ab') | set('bc')
}
returns an instance of
\class
{
frozenset
}
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment