1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
from rpython.rlib.objectmodel import specialize
class AppBridgeCache(object):
w__mean = None
w__var = None
w__std = None
w__commastring = None
w_array_repr = None
w_array_str = None
w__usefields = None
w_partition = None
def __init__(self, space):
pass
@specialize.arg(3)
def call_method(self, space, path, name, args):
w_method = getattr(self, 'w_' + name)
if w_method is None:
w_method = space.appexec([space.newtext(path), space.newtext(name)],
"(path, name): return getattr(__import__(path, fromlist=[name]), name)")
setattr(self, 'w_' + name, w_method)
return space.call_args(w_method, args)
def set_string_function(space, w_f, w_repr):
cache = get_appbridge_cache(space)
if space.is_true(w_repr):
cache.w_array_repr = w_f
else:
cache.w_array_str = w_f
def get_appbridge_cache(space):
return space.fromcache(AppBridgeCache)
|