Commit 27cb4ad5 authored by Mark Florisson's avatar Mark Florisson

Merge branch 'master' of github.com:cython/cython

parents b4f0ba7c 06bb6a93
...@@ -7,6 +7,19 @@ from distutils.extension import Extension ...@@ -7,6 +7,19 @@ from distutils.extension import Extension
from Cython import Utils from Cython import Utils
from Cython.Compiler.Main import Context, CompilationOptions, default_options 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): def cached_method(f):
cache_name = '__%s_cache' % f.__name__ cache_name = '__%s_cache' % f.__name__
def wrapper(self, *args): def wrapper(self, *args):
......
...@@ -14,7 +14,7 @@ from Cython.Compiler.Main import Context, CompilationOptions, default_options ...@@ -14,7 +14,7 @@ from Cython.Compiler.Main import Context, CompilationOptions, default_options
from Cython.Compiler.ParseTreeTransforms import CythonTransform, SkipDeclarations, AnalyseDeclarationsTransform from Cython.Compiler.ParseTreeTransforms import CythonTransform, SkipDeclarations, AnalyseDeclarationsTransform
from Cython.Compiler.TreeFragment import parse_from_strings 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 from Cython.Compiler import Pipeline
import cython as cython_module import cython as cython_module
...@@ -38,6 +38,7 @@ class AllSymbols(CythonTransform, SkipDeclarations): ...@@ -38,6 +38,7 @@ class AllSymbols(CythonTransform, SkipDeclarations):
def visit_NameNode(self, node): def visit_NameNode(self, node):
self.names.add(node.name) self.names.add(node.name)
@cached_function
def unbound_symbols(code, context=None): def unbound_symbols(code, context=None):
code = to_unicode(code) code = to_unicode(code)
if context is None: if context is None:
......
...@@ -65,9 +65,10 @@ class Context(object): ...@@ -65,9 +65,10 @@ class Context(object):
import Builtin, CythonScope import Builtin, CythonScope
self.modules = {"__builtin__" : Builtin.builtin_scope} self.modules = {"__builtin__" : Builtin.builtin_scope}
cyscope = CythonScope.create_cython_scope( if self.cython_scope is None:
Context.cython_scope = CythonScope.create_cython_scope(
self, create_testscope=create_testscope) self, create_testscope=create_testscope)
self.modules["cython"] = self.cython_scope = cyscope self.modules["cython"] = self.cython_scope
self.include_directories = include_directories self.include_directories = include_directories
self.future_directives = set() self.future_directives = set()
self.compiler_directives = compiler_directives self.compiler_directives = compiler_directives
......
__version__ = "0.15+" __version__ = "0.15.1+"
# Void cython.* directives (for case insensitive operating systems). # Void cython.* directives (for case insensitive operating systems).
from Cython.Shadow import * from Cython.Shadow import *
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment