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
8ff66d8c
Commit
8ff66d8c
authored
Jul 26, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid need for statically cached "object" methods by calling faster _PyType_Lookup() in CPython
parent
a1aa7ba8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
+22
-10
Cython/Utility/ExtensionTypes.c
Cython/Utility/ExtensionTypes.c
+22
-10
No files found.
Cython/Utility/ExtensionTypes.c
View file @
8ff66d8c
...
@@ -82,27 +82,36 @@ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
...
@@ -82,27 +82,36 @@ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
static
int
__Pyx_setup_reduce
(
PyObject
*
type_obj
)
{
static
int
__Pyx_setup_reduce
(
PyObject
*
type_obj
)
{
int
ret
=
0
;
int
ret
=
0
;
PyObject
*
builtin_object
=
NULL
;
PyObject
*
object_reduce
=
NULL
;
static
PyObject
*
object_reduce
=
NULL
;
PyObject
*
object_reduce_ex
=
NULL
;
static
PyObject
*
object_reduce_ex
=
NULL
;
PyObject
*
reduce
=
NULL
;
PyObject
*
reduce
=
NULL
;
PyObject
*
reduce_ex
=
NULL
;
PyObject
*
reduce_ex
=
NULL
;
PyObject
*
reduce_cython
=
NULL
;
PyObject
*
reduce_cython
=
NULL
;
PyObject
*
setstate
=
NULL
;
PyObject
*
setstate
=
NULL
;
PyObject
*
setstate_cython
=
NULL
;
PyObject
*
setstate_cython
=
NULL
;
#if CYTHON_COMPILING_IN_CPYTHON
if
(
_PyType_Lookup
((
PyTypeObject
*
)
type_obj
,
PYIDENT
(
"__getstate__"
)))
goto
GOOD
;
#else
if
(
PyObject_HasAttr
(
type_obj
,
PYIDENT
(
"__getstate__"
)))
goto
GOOD
;
if
(
PyObject_HasAttr
(
type_obj
,
PYIDENT
(
"__getstate__"
)))
goto
GOOD
;
#endif
if
(
unlikely
(
!
object_reduce_ex
))
{
#if CYTHON_COMPILING_IN_CPYTHON
Py_CLEAR
(
object_reduce
);
object_reduce_ex
=
_PyType_Lookup
(
&
PyBaseObject_Type
,
PYIDENT
(
"__reduce_ex__"
));
if
(
!
object_reduce_ex
)
goto
BAD
;
builtin_object
=
__Pyx_PyObject_GetAttrStr
(
$
builtins_cname
,
PYIDENT
(
"object"
));
if
(
!
builtin_object
)
goto
BAD
;
#else
object_reduce
=
__Pyx_PyObject_GetAttrStr
(
builtin_object
,
PYIDENT
(
"__reduce__"
));
if
(
!
object_reduce
)
goto
BAD
;
object_reduce_ex
=
__Pyx_PyObject_GetAttrStr
((
PyObject
*
)
&
PyBaseObject_Type
,
PYIDENT
(
"__reduce_ex__"
));
if
(
!
object_reduce_ex
)
goto
BAD
;
object_reduce_ex
=
__Pyx_PyObject_GetAttrStr
(
builtin_object
,
PYIDENT
(
"__reduce_ex__"
));
if
(
!
object_reduce_ex
)
goto
BAD
;
#endif
}
reduce_ex
=
__Pyx_PyObject_GetAttrStr
(
type_obj
,
PYIDENT
(
"__reduce_ex__"
));
if
(
unlikely
(
!
reduce_ex
))
goto
BAD
;
reduce_ex
=
__Pyx_PyObject_GetAttrStr
(
type_obj
,
PYIDENT
(
"__reduce_ex__"
));
if
(
unlikely
(
!
reduce_ex
))
goto
BAD
;
if
(
reduce_ex
==
object_reduce_ex
)
{
if
(
reduce_ex
==
object_reduce_ex
)
{
#if CYTHON_COMPILING_IN_CPYTHON
object_reduce
=
_PyType_Lookup
(
&
PyBaseObject_Type
,
PYIDENT
(
"__reduce__"
));
if
(
!
object_reduce
)
goto
BAD
;
#else
object_reduce
=
__Pyx_PyObject_GetAttrStr
((
PyObject
*
)
&
PyBaseObject_Type
,
PYIDENT
(
"__reduce__"
));
if
(
!
object_reduce
)
goto
BAD
;
#endif
reduce
=
__Pyx_PyObject_GetAttrStr
(
type_obj
,
PYIDENT
(
"__reduce__"
));
if
(
unlikely
(
!
reduce
))
goto
BAD
;
reduce
=
__Pyx_PyObject_GetAttrStr
(
type_obj
,
PYIDENT
(
"__reduce__"
));
if
(
unlikely
(
!
reduce
))
goto
BAD
;
if
(
reduce
==
object_reduce
||
__Pyx_setup_reduce_is_named
(
reduce
,
PYIDENT
(
"__reduce_cython__"
)))
{
if
(
reduce
==
object_reduce
||
__Pyx_setup_reduce_is_named
(
reduce
,
PYIDENT
(
"__reduce_cython__"
)))
{
reduce_cython
=
__Pyx_PyObject_GetAttrStr
(
type_obj
,
PYIDENT
(
"__reduce_cython__"
));
if
(
unlikely
(
!
reduce_cython
))
goto
BAD
;
reduce_cython
=
__Pyx_PyObject_GetAttrStr
(
type_obj
,
PYIDENT
(
"__reduce_cython__"
));
if
(
unlikely
(
!
reduce_cython
))
goto
BAD
;
ret
=
PyDict_SetItem
(((
PyTypeObject
*
)
type_obj
)
->
tp_dict
,
PYIDENT
(
"__reduce__"
),
reduce_cython
);
if
(
unlikely
(
ret
<
0
))
goto
BAD
;
ret
=
PyDict_SetItem
(((
PyTypeObject
*
)
type_obj
)
->
tp_dict
,
PYIDENT
(
"__reduce__"
),
reduce_cython
);
if
(
unlikely
(
ret
<
0
))
goto
BAD
;
...
@@ -125,7 +134,10 @@ BAD:
...
@@ -125,7 +134,10 @@ BAD:
PyErr_Format
(
PyExc_RuntimeError
,
"Unable to initialize pickling for %s"
,
((
PyTypeObject
*
)
type_obj
)
->
tp_name
);
PyErr_Format
(
PyExc_RuntimeError
,
"Unable to initialize pickling for %s"
,
((
PyTypeObject
*
)
type_obj
)
->
tp_name
);
ret
=
-
1
;
ret
=
-
1
;
GOOD:
GOOD:
Py_XDECREF
(
builtin_object
);
#if !CYTHON_COMPILING_IN_CPYTHON
Py_XDECREF
(
object_reduce
);
Py_XDECREF
(
object_reduce_ex
);
#endif
Py_XDECREF
(
reduce
);
Py_XDECREF
(
reduce
);
Py_XDECREF
(
reduce_ex
);
Py_XDECREF
(
reduce_ex
);
Py_XDECREF
(
reduce_cython
);
Py_XDECREF
(
reduce_cython
);
...
...
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