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
4215bcb7
Commit
4215bcb7
authored
Mar 25, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
streamlined builtin next() function
parent
341f8e7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+19
-6
No files found.
Cython/Compiler/Builtin.py
View file @
4215bcb7
...
...
@@ -40,17 +40,30 @@ static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *); /*pro
impl
=
'''
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
PyObject* next;
if (unlikely(!PyIter_Check(iterator))) {
iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(!iternext)) {
#else
if (unlikely(!iternext) || unlikely(!PyIter_Check(iterator))) {
#endif
PyErr_Format(PyExc_TypeError,
"%.200s object is not an iterator",
iterator->ob_type
->tp_name);
"%.200s object is not an iterator",
Py_TYPE(iterator)
->tp_name);
return NULL;
}
next =
(*(Py_TYPE(iterator)->tp_iternext))
(iterator);
if (likely(next))
{
next =
iternext
(iterator);
if (likely(next))
return next;
#if CYTHON_COMPILING_IN_CPYTHON
#if PY_VERSION_HEX >= 0x03010000 || PY_MAJOR_VERSION < 3 && PY_VERSION_HEX >= 0x02070000
if (unlikely(iternext == &_PyObject_NextNotImplemented)) {
return NULL;
#endif
#endif
} else if (defval) {
if (PyErr_Occurred()) {
if(!PyErr_ExceptionMatches(PyExc_StopIteration))
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (unlikely(exc_type != PyExc_StopIteration) &&
!PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))
return NULL;
PyErr_Clear();
}
...
...
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