wolfv / pyjet

JET is a different approach to make numeric python substantially faster
Other
67 stars 5 forks source link

Jet decorator #2

Closed orestis-z closed 7 years ago

wolfv commented 7 years ago

hmmmm it doesn't seem to work with python3 yet :(

especially map, reduce have changed a little bit.

+from itertools import starmap
+
 from compressor import JetBuilder
 from utils import sanitize_name, get_caller_info
 from intake import placeholder
@@ -30,9 +32,12 @@ def jit(*shapes):
                 shapes = [arg.shape if hasattr(arg, 'shape') else () for arg in args]
                 _func_cached_dict[func_id]['shapes'] = shapes

-            ph = map(lambda (idx, name): jet.placeholder(
-                        name=name, shape=shapes[idx]), enumerate(arg_names))
+            get_placeholder = lambda idx, name: jet.placeholder(name=name, shape=shapes[idx])
+            print(list(enumerate(arg_names)))
+            ph = list(starmap(get_placeholder, list(enumerate(arg_names))))

these changes work for the placeholder name getter, but there is some error with the reduce in utils.py...

wolfv commented 7 years ago

Ever saw this?

Traceback (most recent call last):
  File "jet/jit.py", line 79, in <module>
    print(test_func(numpy.array([1, 2]), b))
  File "jet/jit.py", line 44, in wrapper
    func_name=fun_name)),
  File "/home/wolfv/Programs/jet/jet/utils.py", line 81, in get_caller_info
    while reduce(lambda bool_1st, bool_2nd: bool_1st or bool_2nd, map(lambda name: (len(calframe[i][1]) >= len(name) and calframe[i][1][-len(name):] == name) , exclude_list)):
  File "/home/wolfv/Programs/jet/jet/utils.py", line 81, in <lambda>
    while reduce(lambda bool_1st, bool_2nd: bool_1st or bool_2nd, map(lambda name: (len(calframe[i][1]) >= len(name) and calframe[i][1][-len(name):] == name) , exclude_list)):
IndexError: list index out of range
wolfv commented 7 years ago

lgtm!