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
098b84f6
Commit
098b84f6
authored
Mar 28, 2012
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #105 from scoder/_list_append_opt
more optimistic PyList_Append() implementation
parents
dd8ac390
a6afe0e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-1
Cython/Utility/Optimize.c
Cython/Utility/Optimize.c
+19
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
098b84f6
...
...
@@ -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 @
098b84f6
...
...
@@ -2,11 +2,10 @@
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
(
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 +15,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