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
Boxiang Sun
cython
Commits
06bb6a93
Commit
06bb6a93
authored
Sep 20, 2011
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Major speedups to @cython.compile by caching parsing information.
parent
b51af22b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+13
-0
Cython/Build/Inline.py
Cython/Build/Inline.py
+2
-1
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+4
-3
No files found.
Cython/Build/Dependencies.py
View file @
06bb6a93
...
...
@@ -7,6 +7,19 @@ from distutils.extension import Extension
from
Cython
import
Utils
from
Cython.Compiler.Main
import
Context
,
CompilationOptions
,
default_options
def
cached_function
(
f
):
cache_name
=
'__%s_cache'
%
f
.
__name__
def
wrapper
(
*
args
):
cache
=
getattr
(
f
,
cache_name
,
None
)
if
cache
is
None
:
cache
=
{}
setattr
(
f
,
cache_name
,
cache
)
if
args
in
cache
:
return
cache
[
args
]
res
=
cache
[
args
]
=
f
(
*
args
)
return
res
return
wrapper
def
cached_method
(
f
):
cache_name
=
'__%s_cache'
%
f
.
__name__
def
wrapper
(
self
,
*
args
):
...
...
Cython/Build/Inline.py
View file @
06bb6a93
...
...
@@ -14,7 +14,7 @@ from Cython.Compiler.Main import Context, CompilationOptions, default_options
from
Cython.Compiler.ParseTreeTransforms
import
CythonTransform
,
SkipDeclarations
,
AnalyseDeclarationsTransform
from
Cython.Compiler.TreeFragment
import
parse_from_strings
from
Cython.Build.Dependencies
import
strip_string_literals
,
cythonize
from
Cython.Build.Dependencies
import
strip_string_literals
,
cythonize
,
cached_function
from
Cython.Compiler
import
Pipeline
import
cython
as
cython_module
...
...
@@ -38,6 +38,7 @@ class AllSymbols(CythonTransform, SkipDeclarations):
def
visit_NameNode
(
self
,
node
):
self
.
names
.
add
(
node
.
name
)
@
cached_function
def
unbound_symbols
(
code
,
context
=
None
):
code
=
to_unicode
(
code
)
if
context
is
None
:
...
...
Cython/Compiler/Main.py
View file @
06bb6a93
...
...
@@ -65,9 +65,10 @@ class Context(object):
import
Builtin
,
CythonScope
self
.
modules
=
{
"__builtin__"
:
Builtin
.
builtin_scope
}
cyscope
=
CythonScope
.
create_cython_scope
(
self
,
create_testscope
=
create_testscope
)
self
.
modules
[
"cython"
]
=
self
.
cython_scope
=
cyscope
if
self
.
cython_scope
is
None
:
Context
.
cython_scope
=
CythonScope
.
create_cython_scope
(
self
,
create_testscope
=
create_testscope
)
self
.
modules
[
"cython"
]
=
self
.
cython_scope
self
.
include_directories
=
include_directories
self
.
future_directives
=
set
()
self
.
compiler_directives
=
compiler_directives
...
...
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