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
7103e3b6
Commit
7103e3b6
authored
9 years ago
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify flags handling in unbound builtin method call optimisation
parent
72b5113a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
11 deletions
+7
-11
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+6
-8
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+1
-3
No files found.
Cython/Compiler/Code.py
View file @
7103e3b6
...
@@ -425,16 +425,14 @@ class UtilityCode(UtilityCodeBase):
...
@@ -425,16 +425,14 @@ class UtilityCode(UtilityCodeBase):
args = [arg.strip() for arg in args[1:].split(',')]
args = [arg.strip() for arg in args[1:].split(',')]
if len(args) == 1:
if len(args) == 1:
call = '__Pyx_CallUnboundCMethod0'
call = '__Pyx_CallUnboundCMethod0'
flag = 'METH_NOARGS'
output.use_utility_code(UtilityCode.load_cached("
CallUnboundCMethod0
", "
ObjectHandling
.
c
"))
output.use_utility_code(UtilityCode.load_cached("
CallUnboundCMethod0
", "
ObjectHandling
.
c
"))
elif len(args) == 2:
elif len(args) == 2:
call = '__Pyx_CallUnboundCMethod1'
call = '__Pyx_CallUnboundCMethod1'
flag = 'METH_O'
output.use_utility_code(UtilityCode.load_cached("
CallUnboundCMethod1
", "
ObjectHandling
.
c
"))
output.use_utility_code(UtilityCode.load_cached("
CallUnboundCMethod1
", "
ObjectHandling
.
c
"))
else:
else:
assert False, "
CALL_UNBOUND_METHOD
()
requires
1
or
2
call
arguments
"
assert False, "
CALL_UNBOUND_METHOD
()
requires
1
or
2
call
arguments
"
cname = output.get_cached_unbound_method(type_cname, method_name,
flag
)
cname = output.get_cached_unbound_method(type_cname, method_name,
len(args)
)
replacements.append(cname)
replacements.append(cname)
return '%s(&%s, %s)' % (call, cname, ', '.join(args))
return '%s(&%s, %s)' % (call, cname, ', '.join(args))
...
@@ -1219,8 +1217,8 @@ class GlobalState(object):
...
@@ -1219,8 +1217,8 @@ class GlobalState(object):
prefix
=
Naming
.
const_prefix
prefix
=
Naming
.
const_prefix
return
"%s%s"
%
(
prefix
,
name_suffix
)
return
"%s%s"
%
(
prefix
,
name_suffix
)
def
get_cached_unbound_method
(
self
,
type_cname
,
method_name
,
flag
):
def
get_cached_unbound_method
(
self
,
type_cname
,
method_name
,
args_count
):
key
=
(
type_cname
,
method_name
,
flag
)
key
=
(
type_cname
,
method_name
,
args_count
)
try
:
try
:
cname
=
self
.
cached_cmethods
[
key
]
cname
=
self
.
cached_cmethods
[
key
]
except
KeyError
:
except
KeyError
:
...
@@ -1279,11 +1277,11 @@ class GlobalState(object):
...
@@ -1279,11 +1277,11 @@ class GlobalState(object):
w
=
self
.
parts
[
'decls'
]
w
=
self
.
parts
[
'decls'
]
cnames
=
[]
cnames
=
[]
for
(
type_cname
,
method_name
,
flag
),
cname
in
sorted
(
self
.
cached_cmethods
.
iteritems
()):
for
(
type_cname
,
method_name
,
_
),
cname
in
sorted
(
self
.
cached_cmethods
.
iteritems
()):
cnames
.
append
(
cname
)
cnames
.
append
(
cname
)
method_name_cname
=
self
.
get_interned_identifier
(
StringEncoding
.
EncodedString
(
method_name
)).
cname
method_name_cname
=
self
.
get_interned_identifier
(
StringEncoding
.
EncodedString
(
method_name
)).
cname
w
.
putln
(
'static __Pyx_CachedCFunction %s = {(PyObject*)&%s, &%s, 0, 0,
%s
};'
%
(
w
.
putln
(
'static __Pyx_CachedCFunction %s = {(PyObject*)&%s, &%s, 0, 0,
0
};'
%
(
cname
,
type_cname
,
method_name_cname
,
flag
))
cname
,
type_cname
,
method_name_cname
))
if
Options
.
generate_cleanup_code
:
if
Options
.
generate_cleanup_code
:
cleanup
=
self
.
parts
[
'cleanup_globals'
]
cleanup
=
self
.
parts
[
'cleanup_globals'
]
...
...
This diff is collapsed.
Click to expand it.
Cython/Utility/ObjectHandling.c
View file @
7103e3b6
...
@@ -1128,10 +1128,8 @@ static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
...
@@ -1128,10 +1128,8 @@ static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
{
{
PyMethodDescrObject
*
descr
=
(
PyMethodDescrObject
*
)
method
;
PyMethodDescrObject
*
descr
=
(
PyMethodDescrObject
*
)
method
;
target
->
func
=
descr
->
d_method
->
ml_meth
;
target
->
func
=
descr
->
d_method
->
ml_meth
;
if
(
descr
->
d_method
->
ml_flags
&
(
METH_VARARGS
|
METH_KEYWORDS
)
||
!
(
descr
->
d_method
->
ml_flags
&
target
->
flag
))
{
target
->
flag
=
descr
->
d_method
->
ml_flags
&
(
METH_VARARGS
|
METH_KEYWORDS
|
METH_O
|
METH_NOARGS
);
target
->
flag
=
descr
->
d_method
->
ml_flags
&
(
METH_VARARGS
|
METH_KEYWORDS
|
METH_O
|
METH_NOARGS
);
}
}
}
#endif
#endif
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
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