Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
9ba3f98b
Commit
9ba3f98b
authored
May 21, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimise set.update()
parent
3c9e7f25
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+2
-0
tests/run/set.pyx
tests/run/set.pyx
+46
-0
No files found.
Cython/Compiler/Builtin.py
View file @
9ba3f98b
...
@@ -319,6 +319,8 @@ builtin_types_table = [
...
@@ -319,6 +319,8 @@ builtin_types_table = [
BuiltinMethod
(
"clear"
,
"T"
,
"r"
,
"PySet_Clear"
),
BuiltinMethod
(
"clear"
,
"T"
,
"r"
,
"PySet_Clear"
),
# discard() and remove() have a special treatment for unhashable values
# discard() and remove() have a special treatment for unhashable values
# BuiltinMethod("discard", "TO", "r", "PySet_Discard"),
# BuiltinMethod("discard", "TO", "r", "PySet_Discard"),
BuiltinMethod
(
"update"
,
"TO"
,
"r"
,
"__Pyx_PySet_Update"
,
utility_code
=
UtilityCode
.
load_cached
(
"PySet_Update"
,
"Builtins.c"
)),
BuiltinMethod
(
"add"
,
"TO"
,
"r"
,
"PySet_Add"
),
BuiltinMethod
(
"add"
,
"TO"
,
"r"
,
"PySet_Add"
),
BuiltinMethod
(
"pop"
,
"T"
,
"O"
,
"PySet_Pop"
)]),
BuiltinMethod
(
"pop"
,
"T"
,
"O"
,
"PySet_Pop"
)]),
(
"frozenset"
,
"PyFrozenSet_Type"
,
[]),
(
"frozenset"
,
"PyFrozenSet_Type"
,
[]),
...
...
tests/run/set.pyx
View file @
9ba3f98b
...
@@ -71,6 +71,52 @@ def test_set_add():
...
@@ -71,6 +71,52 @@ def test_set_add():
return
s1
return
s1
def
test_set_update
(
v
=
None
):
"""
>>> type(test_set_update()) is _set
True
>>> sorted(test_set_update())
['a', 'b', 'c', 1, 2, (1, 2)]
>>> sorted(test_set_update([]))
['a', 'b', 'c', 1, 2, (1, 2)]
>>> try: test_set_update(object())
... except TypeError: pass
... else: print("NOT RAISED!")
"""
cdef
set
s1
s1
=
set
([
1
,
(
1
,
2
)])
s1
.
update
((
1
,))
s1
.
update
(
'abc'
)
s1
.
update
(
set
([
1
]))
s1
.
update
(
frozenset
((
1
,
2
)))
if
v
is
not
None
:
s1
.
update
(
v
)
return
s1
def
test_object_update
(
v
=
None
):
"""
>>> type(test_object_update()) is _set
True
>>> sorted(test_object_update())
['a', 'b', 'c', 1, 2, (1, 2)]
>>> sorted(test_object_update([]))
['a', 'b', 'c', 1, 2, (1, 2)]
>>> try: test_object_update(object())
... except TypeError: pass
... else: print("NOT RAISED!")
"""
cdef
object
s1
s1
=
set
([
1
,
(
1
,
2
)])
s1
.
update
((
1
,))
s1
.
update
(
'abc'
)
s1
.
update
(
set
([
1
]))
s1
.
update
(
frozenset
((
1
,
2
)))
if
v
is
not
None
:
s1
.
update
(
v
)
return
s1
def
test_set_clear
():
def
test_set_clear
():
"""
"""
>>> type(test_set_clear()) is _set
>>> type(test_set_clear()) is _set
...
...
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