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
80d21af6
Commit
80d21af6
authored
Aug 21, 2002
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sped ._update() method by factoring try/except out of the inner loop.
parent
9f87293b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
Lib/sets.py
Lib/sets.py
+5
-4
No files found.
Lib/sets.py
View file @
80d21af6
...
...
@@ -280,13 +280,14 @@ class BaseSet(object):
def
_update
(
self
,
iterable
):
# The main loop for update() and the subclass __init__() methods.
# XXX This can be optimized a bit by first trying the loop
# without setting up a try/except for each element.
data
=
self
.
_data
value
=
True
for
element
in
iterable
:
it
=
iter
(
iterable
)
while
True
:
try
:
data
[
element
]
=
value
for
element
in
it
:
data
[
element
]
=
value
return
except
TypeError
:
transform
=
getattr
(
element
,
"_as_immutable"
,
None
)
if
transform
is
None
:
...
...
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