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
25c4e3e0
Commit
25c4e3e0
authored
Jan 25, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify specialised GenericGetAttr implementation.
parent
2b0870ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
22 deletions
+17
-22
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+17
-22
No files found.
Cython/Utility/ObjectHandling.c
View file @
25c4e3e0
...
...
@@ -1230,7 +1230,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObj
/////////////// PyObject_GenericGetAttrNoDict.proto ///////////////
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP
static
PyObject
*
__Pyx_PyObject_GenericGetAttrNoDict
(
PyObject
*
obj
,
PyObject
*
attr_name
);
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_GenericGetAttrNoDict
(
PyObject
*
obj
,
PyObject
*
attr_name
);
#else
// No-args macro to allow function pointer assignment.
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
...
...
@@ -1252,12 +1252,11 @@ static PyObject *__Pyx_RaiseGenericAttributeError(PyTypeObject *tp, PyObject *at
return
NULL
;
}
static
PyObject
*
__Pyx_PyObject_GenericGetAttrNoDict
(
PyObject
*
obj
,
PyObject
*
attr_name
)
{
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_GenericGetAttrNoDict
(
PyObject
*
obj
,
PyObject
*
attr_name
)
{
// Copied and adapted from _PyObject_GenericGetAttrWithDict() in CPython 2.6/3.7.
// To be used in the "tp_getattro" slot of extension types that have no instance dict and cannot be subclassed.
PyObject
*
descr
,
*
res
;
PyObject
*
descr
;
PyTypeObject
*
tp
=
Py_TYPE
(
obj
);
descrgetfunc
f
=
NULL
;
if
(
unlikely
(
!
PyString_Check
(
attr_name
)))
{
return
PyObject_GenericGetAttr
(
obj
,
attr_name
);
...
...
@@ -1265,29 +1264,25 @@ static PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* at
assert
(
!
tp
->
tp_dictoffset
);
descr
=
_PyType_Lookup
(
tp
,
attr_name
);
if
(
descr
#if PY_MAJOR_VERSION < 3
&&
likely
(
PyType_HasFeature
(
Py_TYPE
(
descr
),
Py_TPFLAGS_HAVE_CLASS
))
#endif
)
{
f
=
Py_TYPE
(
descr
)
->
tp_descr_get
;
if
(
unlikely
(
!
descr
))
{
return
__Pyx_RaiseGenericAttributeError
(
tp
,
attr_name
);
}
Py_INCREF
(
descr
);
#if PY_MAJOR_VERSION < 3
if
(
likely
(
PyType_HasFeature
(
Py_TYPE
(
descr
),
Py_TPFLAGS_HAVE_CLASS
)))
#endif
{
descrgetfunc
f
=
Py_TYPE
(
descr
)
->
tp_descr_get
;
// Optimise for the non-descriptor case because it is faster.
if
(
unlikely
(
f
))
{
Py_INCREF
(
descr
);
res
=
f
(
descr
,
obj
,
(
PyObject
*
)
tp
);
PyObject
*
res
=
f
(
descr
,
obj
,
(
PyObject
*
)
tp
);
Py_DECREF
(
descr
);
goto
done
;
return
res
;
}
}
if
(
likely
(
descr
))
{
Py_INCREF
(
descr
);
res
=
descr
;
goto
done
;
}
return
__Pyx_RaiseGenericAttributeError
(
tp
,
attr_name
);
done:
return
res
;
return
descr
;
}
#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