GeezerVison is showing github.com — Add call extended to call with kwargs · mjdhasan/egglog-python@30fde13
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: python/egglog/builtins.py +8-2Lines changed: 8 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -994,6 +994,12 @@ def __init__(self, value: object) -> None: ... | 994 | 994 | @method(egg_fn="py-call") | 995 | 995 | def __call__(self, *args: object) -> PyObject: ... | 996 | 996 |
| | 997 | + @method(egg_fn="py-call-extended") | | 998 | + def call_extended(self, args: PyObject, kwargs: PyObject) -> PyObject: | | 999 | + """ | | 1000 | + Call the PyObject with the given args and kwargs PyObjects. | | 1001 | + """ | | 1002 | + | 997 | 1003 | @method(egg_fn="py-from-string") | 998 | 1004 | @classmethod | 999 | 1005 | def from_string(cls, s: StringLike) -> PyObject: ... | @@ -1052,7 +1058,7 @@ def py_exec(code: StringLike, globals: object = PyObject.dict(), locals: object | 1052 | 1058 | T3 = TypeVar("T3") | 1053 | 1059 |
| 1054 | 1060 |
| 1055 | | -class UnstableFn(BuiltinExpr, Generic[T, Unpack[TS]], egg_sort="UnstableFn"): | | 1061 | +class UnstableFn(BuiltinExpr, Generic[T, *TS], egg_sort="UnstableFn"): | 1056 | 1062 | @overload | 1057 | 1063 | def __init__(self, f: Callable[[Unpack[TS]], T]) -> None: ... | 1058 | 1064 |
| @@ -1090,7 +1096,7 @@ def value(self) -> Callable[[Unpack[TS]], T]: | 1090 | 1096 | __match_args__ = ("value",) | 1091 | 1097 |
| 1092 | 1098 | @method(egg_fn="unstable-app") | 1093 | | - def __call__(self, *args: Unpack[TS]) -> T: ... | | 1099 | + def __call__(self, *args: *TS) -> T: ... | 1094 | 1100 |
| 1095 | 1101 |
| 1096 | 1102 | # Method Type is for builtins like __getitem__ | |
Collapse file Copy file name to clipboardExpand all lines: src/py_object_sort.rs +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -118,6 +118,13 @@ impl BaseSort for PyObjectSort { | 118 | 118 | }) | 119 | 119 | }); | 120 | 120 |
| | 121 | + // (py-call-extended <fn-obj> <args-obj> <kwargs-obj>) | | 122 | + add_primitive!(eg, "py-call-extended" = |fn_: PyPickledValue, args: PyPickledValue, kwargs: PyPickledValue| -?> PyPickledValue { | | 123 | + attach("py-call-extended", |py| { | | 124 | + let fn_ = load(py, &fn_)?; | | 125 | + let args = load(py, &args)?; | | 126 | + let kwargs = load(py, &kwargs)?; | | 127 | + dump(fn_.call(args.cast::<PyTuple>().map_err(|e| {e})?, Some(kwargs.cast::<PyDict>()?))?) | 121 | 128 | }) | 122 | 129 | }); | 123 | 130 |
| |
|