Skip to content

Commit

Permalink
optimize conversion to python Program class
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Feb 8, 2024
1 parent 4b0ac5b commit 73d4074
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 3 additions & 10 deletions chia-protocol/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,9 @@ fn clvm_serialize(a: &mut Allocator, o: &PyAny) -> PyResult<NodePtr> {

#[cfg(feature = "py-bindings")]
fn to_program(py: Python<'_>, node: LazyNode) -> PyResult<&PyAny> {
use pyo3::types::PyDict;
let ctx: &PyDict = PyDict::new(py);
ctx.set_item("node", node)?;
py.run(
"from chia.types.blockchain_format.program import Program\n\
ret = Program(node)\n",
None,
Some(ctx),
)?;
Ok(ctx.get_item("ret").unwrap())
let int_module = PyModule::import(py, "chia.types.blockchain_format.program")?;
let ty = int_module.getattr("Program")?;
ty.call1((node.into_py(py),))
}

#[cfg(feature = "py-bindings")]
Expand Down

0 comments on commit 73d4074

Please sign in to comment.