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
76f2ea63
Commit
76f2ea63
authored
Mar 08, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
speed up object attribute setting a little
parent
8f428c03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+4
-2
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+17
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
76f2ea63
...
...
@@ -1837,7 +1837,7 @@ class NameNode(AtomicExprNode):
elif
entry
.
is_pyclass_attr
:
setter
=
'PyObject_SetItem'
else
:
setter
=
'PyObject_SetAttr'
assert
False
,
repr
(
entry
)
code
.
put_error_if_neg
(
self
.
pos
,
'%s(%s, %s, %s)'
%
(
...
...
@@ -5171,8 +5171,10 @@ class AttributeNode(ExprNode):
def
generate_assignment_code
(
self
,
rhs
,
code
):
self
.
obj
.
generate_evaluation_code
(
code
)
if
self
.
is_py_attr
:
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"PyObjectSetAttrStr"
,
"ObjectHandling.c"
))
code
.
put_error_if_neg
(
self
.
pos
,
'
PyObject_SetAt
tr(%s, %s, %s)'
%
(
'
__Pyx_PyObject_SetAttrS
tr(%s, %s, %s)'
%
(
self
.
obj
.
py_result
(),
code
.
intern_identifier
(
self
.
attribute
),
rhs
.
py_result
()))
...
...
Cython/Utility/ObjectHandling.c
View file @
76f2ea63
...
...
@@ -657,6 +657,23 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif
/////////////// PyObjectSetAttrStr.proto ///////////////
#if CYTHON_COMPILING_IN_CPYTHON
static
CYTHON_INLINE
int
__Pyx_PyObject_SetAttrStr
(
PyObject
*
obj
,
PyObject
*
attr_name
,
PyObject
*
value
)
{
PyTypeObject
*
tp
=
Py_TYPE
(
obj
);
if
(
likely
(
tp
->
tp_setattro
))
return
tp
->
tp_setattro
(
obj
,
attr_name
,
value
);
#if PY_MAJOR_VERSION < 3
if
(
likely
(
tp
->
tp_setattr
))
return
tp
->
tp_setattr
(
obj
,
PyString_AS_STRING
(
attr_name
),
value
);
#endif
return
PyObject_SetAttr
(
obj
,
attr_name
,
value
);
}
#else
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif
/////////////// PyObjectCallMethod.proto ///////////////
//@requires: PyObjectGetAttrStr
//@substitute: naming
...
...
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