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
93bbdc16
Commit
93bbdc16
authored
Jan 19, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inline PyObject_Call()
parent
12706ee0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
4 deletions
+46
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+9
-3
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+37
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
93bbdc16
...
...
@@ -2536,7 +2536,9 @@ class WithExitCallNode(ExprNode):
result_var
=
code
.
funcstate
.
allocate_temp
(
py_object_type
,
manage_ref
=
False
)
code
.
mark_pos
(
self
.
pos
)
code
.
putln
(
"%s = PyObject_Call(%s, %s, NULL);"
%
(
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"PyObjectCall"
,
"ObjectHandling.c"
))
code
.
putln
(
"%s = __Pyx_PyObject_Call(%s, %s, NULL);"
%
(
result_var
,
self
.
with_stat
.
exit_var
,
self
.
args
.
result
()))
...
...
@@ -4657,8 +4659,10 @@ class SimpleCallNode(CallNode):
code
.
globalstate
.
use_utility_code
(
self
.
function
.
entry
.
utility_code
)
if
func_type
.
is_pyobject
:
arg_code
=
self
.
arg_tuple
.
py_result
()
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"PyObjectCall"
,
"ObjectHandling.c"
))
code
.
putln
(
"%s = PyObject_Call(%s, %s, NULL); %s"
%
(
"%s =
__Pyx_
PyObject_Call(%s, %s, NULL); %s"
%
(
self
.
result
(),
self
.
function
.
py_result
(),
arg_code
,
...
...
@@ -5087,8 +5091,10 @@ class GeneralCallNode(CallNode):
kwargs
=
self
.
keyword_args
.
py_result
()
else
:
kwargs
=
'NULL'
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"PyObjectCall"
,
"ObjectHandling.c"
))
code
.
putln
(
"%s = PyObject_Call(%s, %s, %s); %s"
%
(
"%s =
__Pyx_
PyObject_Call(%s, %s, %s); %s"
%
(
self
.
result
(),
self
.
function
.
py_result
(),
self
.
positional_args
.
py_result
(),
...
...
Cython/Utility/ObjectHandling.c
View file @
93bbdc16
...
...
@@ -1093,6 +1093,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr
/////////////// PyObjectCallMethod.proto ///////////////
//@requires: PyObjectGetAttrStr
//@requires: PyObjectCall
//@substitute: naming
static
PyObject
*
__Pyx_PyObject_CallMethodTuple
(
PyObject
*
obj
,
PyObject
*
method_name
,
PyObject
*
args
)
{
...
...
@@ -1100,7 +1101,7 @@ static PyObject* __Pyx_PyObject_CallMethodTuple(PyObject* obj, PyObject* method_
if
(
unlikely
(
!
args
))
return
NULL
;
method
=
__Pyx_PyObject_GetAttrStr
(
obj
,
method_name
);
if
(
unlikely
(
!
method
))
goto
bad
;
result
=
PyObject_Call
(
method
,
args
,
NULL
);
result
=
__Pyx_
PyObject_Call
(
method
,
args
,
NULL
);
Py_DECREF
(
method
);
bad:
Py_DECREF
(
args
);
...
...
@@ -1123,3 +1124,38 @@ bad:
static
CYTHON_INLINE
PyObject
*
__Pyx_tp_new_kwargs
(
PyObject
*
type_obj
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
return
(
PyObject
*
)
(((
PyTypeObject
*
)
type_obj
)
->
tp_new
((
PyTypeObject
*
)
type_obj
,
args
,
kwargs
));
}
/////////////// PyObjectCall.proto ///////////////
#if CYTHON_COMPILING_IN_CPYTHON
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_Call
(
PyObject
*
func
,
PyObject
*
arg
,
PyObject
*
kw
);
/*proto*/
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif
/////////////// PyObjectCall ///////////////
#if CYTHON_COMPILING_IN_CPYTHON
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_Call
(
PyObject
*
func
,
PyObject
*
arg
,
PyObject
*
kw
)
{
PyObject
*
result
;
ternaryfunc
call
=
func
->
ob_type
->
tp_call
;
if
(
unlikely
(
!
call
))
return
PyObject_Call
(
func
,
arg
,
kw
);
#if PY_VERSION_HEX >= 0x02060000
if
(
unlikely
(
Py_EnterRecursiveCall
(
" while calling a Python object"
)))
return
NULL
;
#endif
result
=
(
*
call
)(
func
,
arg
,
kw
);
#if PY_VERSION_HEX >= 0x02060000
Py_LeaveRecursiveCall
();
#endif
if
(
unlikely
(
!
result
)
&&
unlikely
(
!
PyErr_Occurred
()))
{
PyErr_SetString
(
PyExc_SystemError
,
"NULL result without error in PyObject_Call"
);
}
return
result
;
}
#endif
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