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
d6bc4573
Commit
d6bc4573
authored
Dec 09, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix getattr() optimisation
parent
9614a25e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
27 deletions
+29
-27
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+29
-27
No files found.
Cython/Compiler/Optimize.py
View file @
d6bc4573
...
...
@@ -843,33 +843,6 @@ class EarlyReplaceBuiltinCalls(Visitor.EnvTransform):
return
replace_in
(
arg
)
return
node
PyObject_GetAttr2_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
py_object_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"object"
,
PyrexTypes
.
py_object_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"attr_name"
,
PyrexTypes
.
py_object_type
,
None
),
])
PyObject_GetAttr3_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
py_object_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"object"
,
PyrexTypes
.
py_object_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"attr_name"
,
PyrexTypes
.
py_object_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"default"
,
PyrexTypes
.
py_object_type
,
None
),
])
def
_handle_simple_function_getattr
(
self
,
node
,
pos_args
):
if
len
(
pos_args
)
==
2
:
self
.
_inject_capi_function
(
node
,
"PyObject_GetAttr"
,
self
.
PyObject_GetAttr2_func_type
)
elif
len
(
pos_args
)
==
3
:
self
.
_inject_capi_function
(
node
,
"__Pyx_GetAttr3"
,
self
.
PyObject_GetAttr3_func_type
,
Builtin
.
getattr3_utility_code
)
else
:
self
.
_error_wrong_arg_count
(
'getattr'
,
node
,
pos_args
,
'2 or 3'
)
return
node
Pyx_Type_func_type
=
PyrexTypes
.
CFuncType
(
Builtin
.
type_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"object"
,
PyrexTypes
.
py_object_type
,
None
)
...
...
@@ -1160,6 +1133,35 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
### builtin functions
PyObject_GetAttr2_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
py_object_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"object"
,
PyrexTypes
.
py_object_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"attr_name"
,
PyrexTypes
.
py_object_type
,
None
),
])
PyObject_GetAttr3_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
py_object_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"object"
,
PyrexTypes
.
py_object_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"attr_name"
,
PyrexTypes
.
py_object_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"default"
,
PyrexTypes
.
py_object_type
,
None
),
])
def
_handle_simple_function_getattr
(
self
,
node
,
pos_args
):
if
len
(
pos_args
)
==
2
:
return
ExprNodes
.
PythonCapiCallNode
(
node
.
pos
,
"PyObject_GetAttr"
,
self
.
PyObject_GetAttr2_func_type
,
args
=
pos_args
,
is_temp
=
node
.
is_temp
)
elif
len
(
pos_args
)
==
3
:
return
ExprNodes
.
PythonCapiCallNode
(
node
.
pos
,
"__Pyx_GetAttr3"
,
self
.
PyObject_GetAttr3_func_type
,
args
=
pos_args
,
is_temp
=
node
.
is_temp
,
utility_code
=
Builtin
.
getattr3_utility_code
)
else
:
self
.
_error_wrong_arg_count
(
'getattr'
,
node
,
pos_args
,
'2 or 3'
)
return
node
Pyx_strlen_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
c_size_t_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"bytes"
,
PyrexTypes
.
c_char_ptr_type
,
None
)
...
...
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