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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
fd7b1751
Commit
fd7b1751
authored
Jul 31, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimise object.pop() for sets
--HG-- extra : rebase_source : a4c51d10f4b7c88a994a0687202ac032a7baff33
parent
b04e040d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+4
-6
tests/run/set.pyx
tests/run/set.pyx
+11
-0
No files found.
Cython/Compiler/Optimize.py
View file @
fd7b1751
...
...
@@ -3098,7 +3098,6 @@ impl = ""
pop_utility_code
=
UtilityCode
(
proto
=
"""
static CYTHON_INLINE PyObject* __Pyx_PyObject_Pop(PyObject* L) {
PyObject *r, *m;
#if PY_VERSION_HEX >= 0x02040000
if (likely(PyList_CheckExact(L))
/* Check that both the size is positive and no reallocation shrinking needs to be done. */
...
...
@@ -3106,12 +3105,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Pop(PyObject* L) {
Py_SIZE(L) -= 1;
return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
}
else if (Py_TYPE(L) == (&PySet_Type)) {
return PySet_Pop(L);
}
#endif
m = __Pyx_GetAttrString(L, "pop");
if (!m) return NULL;
r = PyObject_CallObject(m, NULL);
Py_DECREF(m);
return r;
return PyObject_CallMethod(L, (char*)"pop", NULL);
}
"""
,
impl
=
""
...
...
tests/run/set.pyx
View file @
fd7b1751
...
...
@@ -89,6 +89,17 @@ def test_set_pop():
two
=
s1
.
pop
()
return
s1
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode//NameNode"
)
def
test_object_pop
(
s
):
"""
>>> s = _set([2])
>>> test_object_pop(s)
2
>>> list(s)
[]
"""
return
s
.
pop
()
def
test_set_discard
():
"""
>>> type(test_set_discard()) 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