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
a40112b0
Commit
a40112b0
authored
Apr 25, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimise built-in callable() function
parent
bd50b09a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+2
-0
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+8
-0
tests/run/builtin_callable.pyx
tests/run/builtin_callable.pyx
+19
-0
No files found.
Cython/Compiler/Builtin.py
View file @
a40112b0
...
...
@@ -333,6 +333,8 @@ builtin_function_table = [
],
is_strict_signature
=
True
)),
BuiltinFunction
(
'abs'
,
"O"
,
"O"
,
"PyNumber_Absolute"
),
BuiltinFunction
(
'callable'
,
"O"
,
"b"
,
"__Pyx_PyCallable_Check"
,
utility_code
=
UtilityCode
.
load_cached
(
"CallableCheck"
,
"ObjectHandling.c"
)),
#('chr', "", "", ""),
#('cmp', "", "", "", ""), # int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result)
#('compile', "", "", ""), # PyObject* Py_CompileString( char *str, char *filename, int start)
...
...
Cython/Utility/ObjectHandling.c
View file @
a40112b0
...
...
@@ -432,3 +432,11 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
Py_TYPE
(
obj
)
->
tp_name
,
type
->
tp_name
);
return
0
;
}
/////////////// CallableCheck.proto ///////////////
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL)
#else
#define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj)
#endif
tests/run/builtin_callable.pyx
0 → 100644
View file @
a40112b0
# mode: run
# tag: builtin, callable
cimport
cython
@
cython
.
test_assert_path_exists
(
"//SimpleCallNode[@type.is_pyobject = False]"
)
def
test_callable
(
x
):
"""
>>> test_callable(None)
False
>>> test_callable('ABC')
False
>>> test_callable(int)
True
>>> test_callable(test_callable)
True
"""
b
=
callable
(
x
)
return
b
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