Commit 7e83c636 authored by Stefan Behnel's avatar Stefan Behnel

less aggressive callable() optimisation in Py2

parent 698f7535
...@@ -435,7 +435,7 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { ...@@ -435,7 +435,7 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
/////////////// CallableCheck.proto /////////////// /////////////// CallableCheck.proto ///////////////
#if CYTHON_COMPILING_IN_CPYTHON #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL) #define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL)
#else #else
#define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj) #define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj)
......
...@@ -10,6 +10,13 @@ def test_callable(x): ...@@ -10,6 +10,13 @@ def test_callable(x):
False False
>>> test_callable('ABC') >>> test_callable('ABC')
False False
>>> class C: pass
>>> test_callable(C)
True
>>> test_callable(C())
False
>>> test_callable(int) >>> test_callable(int)
True True
>>> test_callable(test_callable) >>> test_callable(test_callable)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment