Skip to content

Commit

Permalink
Add example of passing a class as the function
Browse files Browse the repository at this point in the history
  • Loading branch information
JosepSampe committed Nov 21, 2022
1 parent d02b1a7 commit 9731597
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/call_async_class.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Simple Lithops example using one single function invocation
with a class as a function and a function as a parameter
"""
import lithops

def mult(x, y):
return x + y


class MyClass:
def __init__(self, base) -> None:
self.base = base

def __call__(self, x, fn) -> int:
return fn(self.base, x)


if __name__ == '__main__':
fexec = lithops.FunctionExecutor()
inst = MyClass(7)
fexec.map(inst, [(8, mult), (6, mult)])
print(fexec.get_result())

0 comments on commit 9731597

Please sign in to comment.