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
39172312
Commit
39172312
authored
May 22, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor utility code inclusion for optimised unbound method calls
parent
7a6c4e2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+7
-5
No files found.
Cython/Compiler/Code.py
View file @
39172312
...
...
@@ -419,26 +419,28 @@ class UtilityCode(UtilityCodeBase):
if 'CALL_UNBOUND_METHOD(' not in impl:
return False, impl
replacements = []
utility_code = set()
def externalise(matchobj):
type_cname, method_name, args = matchobj.groups()
args = [arg.strip() for arg in args[1:].split(',')]
if len(args) == 1:
call = '__Pyx_CallUnboundCMethod0'
output.use_utility_code(UtilityCode.load_cached("
CallUnboundCMethod0
", "
ObjectHandling
.
c
")
)
utility_code.add("
CallUnboundCMethod0
"
)
elif len(args) == 2:
call = '__Pyx_CallUnboundCMethod1'
output.use_utility_code(UtilityCode.load_cached("
CallUnboundCMethod1
", "
ObjectHandling
.
c
")
)
utility_code.add("
CallUnboundCMethod1
"
)
else:
assert False, "
CALL_UNBOUND_METHOD
()
requires
1
or
2
call
arguments
"
cname = output.get_cached_unbound_method(type_cname, method_name, len(args))
replacements.append(cname)
return '%s(&%s, %s)' % (call, cname, ', '.join(args))
impl = re.sub(r'CALL_UNBOUND_METHOD
\
(([
a
-zA-Z_]+),
\
s*
"
([^"
]
+
)
"((?:,
\
s*[^),]+)+)
\
)', externalise, impl)
assert 'CALL_UNBOUND_METHOD(' not in impl
return bool(replacements), impl
for helper in sorted(utility_code):
output.use_utility_code(UtilityCode.load_cached(helper, "
ObjectHandling
.
c
"))
return bool(utility_code), impl
def wrap_c_strings(self, impl):
"""Replace CSTRING('''xyz''') by a C compatible string
...
...
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