diff --git a/python/egglog/builtins.py b/python/egglog/builtins.py index a9c75f69..c8b9ac09 100644 --- a/python/egglog/builtins.py +++ b/python/egglog/builtins.py @@ -1022,6 +1022,9 @@ def to_string(self) -> String: ... @method(egg_fn="py-to-bool") def to_bool(self) -> Bool: ... + @method(egg_fn="py-to-int") + def to_int(self) -> i64: ... + @method(egg_fn="py-dict-update") def dict_update(self, *keys_and_values: object) -> PyObject: ... diff --git a/src/py_object_sort.rs b/src/py_object_sort.rs index 51de73f9..ad4859ed 100644 --- a/src/py_object_sort.rs +++ b/src/py_object_sort.rs @@ -170,6 +170,15 @@ impl BaseSort for PyObjectSort { } } ); + // (py-to-int ) + add_primitive!( + eg, + "py-to-int" = |x: PyPickledValue| -?> i64 { + { + attach("py-to-int", move |py| load(py, &x)?.extract()) + } + } + ); // (py-from-string ) add_primitive!( eg,