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
Boxiang Sun
cython
Commits
adb4693e
Commit
adb4693e
authored
Mar 28, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more optimistic PyList_Append() implementation
parent
dd8ac390
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-1
Cython/Utility/Optimize.c
Cython/Utility/Optimize.c
+20
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
adb4693e
...
...
@@ -5443,7 +5443,8 @@ class ComprehensionAppendNode(Node):
def
generate_execution_code
(
self
,
code
):
if
self
.
target
.
type
is
list_type
:
function
=
"PyList_Append"
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"InternalListAppend"
,
"Optimize.c"
))
function
=
"__Pyx_PyList_Append"
elif
self
.
target
.
type
is
set_type
:
function
=
"PySet_Add"
else
:
...
...
Cython/Utility/Optimize.c
View file @
adb4693e
/////////////// append.proto ///////////////
//@requires: InternalListAppend
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_Append
(
PyObject
*
L
,
PyObject
*
x
)
{
if
(
likely
(
PyList_CheckExact
(
L
)))
{
if
(
PyList_Append
(
L
,
x
)
<
0
)
return
NULL
;
if
(
unlikely
(
__Pyx_PyList_Append
(
L
,
x
)
<
0
)
)
return
NULL
;
Py_INCREF
(
Py_None
);
return
Py_None
;
/* this is just to have an accurate signature */
}
else
{
}
else
{
PyObject
*
r
,
*
m
;
m
=
__Pyx_GetAttrString
(
L
,
"append"
);
if
(
!
m
)
return
NULL
;
...
...
@@ -16,6 +16,23 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
}
}
/////////////// InternalListAppend.proto ///////////////
#if CYTHON_COMPILING_IN_CPYTHON
static
CYTHON_INLINE
int
__Pyx_PyList_Append
(
PyObject
*
list
,
PyObject
*
x
)
{
PyListObject
*
L
=
(
PyListObject
*
)
list
;
Py_ssize_t
len
=
Py_SIZE
(
list
);
if
(
likely
(
L
->
allocated
>
len
))
{
Py_INCREF
(
x
);
PyList_SET_ITEM
(
list
,
len
,
x
);
Py_SIZE
(
list
)
=
len
+
1
;
return
0
;
}
return
PyList_Append
(
list
,
x
);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif
/////////////// pop.proto ///////////////
...
...
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