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
c5c29c0a
Commit
c5c29c0a
authored
Sep 12, 2010
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use weakrefs for both forward and backward links.
parent
b084b48c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
Lib/collections.py
Lib/collections.py
+4
-3
No files found.
Lib/collections.py
View file @
c5c29c0a
...
...
@@ -31,7 +31,9 @@ class OrderedDict(dict, MutableMapping):
# The internal self.__map dictionary maps keys to links in a doubly linked list.
# The circular doubly linked list starts and ends with a sentinel element.
# The sentinel element never gets deleted (this simplifies the algorithm).
# The back links are weakref proxies (to prevent circular references).
# The prev/next links are weakref proxies (to prevent circular references).
# Individual links are kept alive by the hard reference in self.__map.
# Those hard references disappear when a key is deleted from an OrderedDict.
def
__init__
(
self
,
*
args
,
**
kwds
):
'''Initialize an ordered dictionary. Signature is the same as for
...
...
@@ -60,8 +62,7 @@ class OrderedDict(dict, MutableMapping):
root
=
self
.
__root
last
=
root
.
prev
link
.
prev
,
link
.
next
,
link
.
key
=
last
,
root
,
key
last
.
next
=
link
root
.
prev
=
proxy
(
link
)
last
.
next
=
root
.
prev
=
proxy
(
link
)
dict
.
__setitem__
(
self
,
key
,
value
)
def
__delitem__
(
self
,
key
,
dict_delitem
=
dict
.
__delitem__
):
...
...
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