Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/egglog/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

Expand Down
9 changes: 9 additions & 0 deletions src/py_object_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ impl BaseSort for PyObjectSort {
}
}
);
// (py-to-int <obj>)
add_primitive!(
eg,
"py-to-int" = |x: PyPickledValue| -?> i64 {
{
attach("py-to-int", move |py| load(py, &x)?.extract())
}
}
);
// (py-from-string <str>)
add_primitive!(
eg,
Expand Down