Skip to content

Commit

Permalink
[token-swap] Upgrade PyO3 from 0.12.3 to 0.15.1 (#2673)
Browse files Browse the repository at this point in the history
* Update PyO3 from 0.12.3 to 0.15.1

* run cargo fmt --all
  • Loading branch information
peyton authored Dec 30, 2021
1 parent 48f31d5 commit c5d7381
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion token-swap/program/sim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
pyo3 = "0.12.3"
pyo3 = { version = "0.15.1", features = ["auto-initialize"] }
40 changes: 18 additions & 22 deletions token-swap/program/sim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,15 @@ impl StableSwapModel {
fn call0(&self, py: Python, method_name: &str) -> Result<PyObject, PyErr> {
let sim = PyModule::from_code(py, &self.py_src, FILE_NAME, MODULE_NAME).unwrap();
let model = sim
.call1(
"Curve",
(
self.amp_factor,
self.balances.to_vec(),
self.n_coins,
self.fee,
self.target_prices.to_vec(),
self.pool_tokens,
),
)
.getattr("Curve")?
.call1((
self.amp_factor,
self.balances.to_vec(),
self.n_coins,
self.fee,
self.target_prices.to_vec(),
self.pool_tokens,
))
.unwrap()
.to_object(py);
let py_ret = model.as_ref(py).call_method0(method_name);
Expand All @@ -164,17 +162,15 @@ impl StableSwapModel {
) -> Result<PyObject, PyErr> {
let sim = PyModule::from_code(py, &self.py_src, FILE_NAME, MODULE_NAME).unwrap();
let model = sim
.call1(
"Curve",
(
self.amp_factor,
self.balances.to_vec(),
self.n_coins,
self.fee,
self.target_prices.to_vec(),
self.pool_tokens,
),
)
.getattr("Curve")?
.call1((
self.amp_factor,
self.balances.to_vec(),
self.n_coins,
self.fee,
self.target_prices.to_vec(),
self.pool_tokens,
))
.unwrap()
.to_object(py);
let py_ret = model.as_ref(py).call_method1(method_name, args);
Expand Down

0 comments on commit c5d7381

Please sign in to comment.