vrtnis
vrtnis
MModular
Created by Martin Dudek on 5/16/2024 in #questions
Python integration and performance
ohh got it..makes sense!
10 replies
MModular
Created by Martin Dudek on 5/16/2024 in #questions
Python integration and performance
also, just building on the comment above, for now it seems like we'd have to handle such issues on a case-by-case basis rather than a general approach. here it could be something like: utils.py def get_dict_and_modify(num): di = {} for i in range(num): di[str(i*2)] = i%3 for key in dic.keys(): di[key] *= 2 return di and then from python import Python from time import now alias NUM = 1_000_000 fn main() raises: start = now() Python.add_to_path("./utils") var utils: PythonObject = Python.import_module("utils") var dict = utils.get_dict_and_modify(NUM) var elapsed = (now()-start)/1_000_000_000 print("time:", elapsed, "sec") _ = dict["112"]
10 replies
MModular
Created by Martin Dudek on 5/16/2024 in #questions
Python integration and performance
wondering if, in this example, we can minimize the number of calls between mojo and python. perhaps batch operations together in python as much as possible before passing the result to mojo
10 replies