Skip to content

Commit 7377664

Browse files
committed
Remove PyFloatRef
1 parent cd2edbc commit 7377664

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

stdlib/src/math.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ pub(crate) use math::make_module;
33
#[pymodule]
44
mod math {
55
use crate::vm::{
6-
builtins::{try_bigint_to_f64, try_f64_to_bigint, PyFloatRef, PyInt, PyIntRef},
6+
builtins::{try_bigint_to_f64, try_f64_to_bigint, PyFloat, PyInt, PyIntRef},
77
function::{ArgIntoFloat, ArgIterable, OptionalArg, PosArgs},
88
utils::Either,
9-
PyObjectRef, PyResult, PySequence, TypeProtocol, VirtualMachine,
9+
PyObjectRef, PyRef, PyResult, PySequence, TypeProtocol, VirtualMachine,
1010
};
1111
use num_bigint::BigInt;
1212
use num_traits::{One, Signed, Zero};
@@ -460,7 +460,11 @@ mod math {
460460
}
461461

462462
#[pyfunction]
463-
fn ldexp(x: Either<PyFloatRef, PyIntRef>, i: PyIntRef, vm: &VirtualMachine) -> PyResult<f64> {
463+
fn ldexp(
464+
x: Either<PyRef<PyFloat>, PyIntRef>,
465+
i: PyIntRef,
466+
vm: &VirtualMachine,
467+
) -> PyResult<f64> {
464468
let value = match x {
465469
Either::A(f) => f.to_f64(),
466470
Either::B(z) => try_bigint_to_f64(z.as_bigint(), vm)?,

vm/src/builtins/float.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ macro_rules! impl_try_from_object_float {
9494
($($t:ty),*) => {
9595
$(impl TryFromObject for $t {
9696
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> {
97-
PyFloatRef::try_from_object(vm, obj).map(|f| f.to_f64() as $t)
97+
PyRef::<PyFloat>::try_from_object(vm, obj).map(|f| f.to_f64() as $t)
9898
}
9999
})*
100100
};
@@ -539,8 +539,6 @@ impl Hashable for PyFloat {
539539
}
540540
}
541541

542-
pub type PyFloatRef = PyRef<PyFloat>;
543-
544542
// Retrieve inner float value:
545543
pub(crate) fn get_value(obj: &PyObjectRef) -> f64 {
546544
obj.payload::<PyFloat>().unwrap().value

vm/src/builtins/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub use enumerate::PyEnumerate;
2222
pub(crate) mod filter;
2323
pub use filter::PyFilter;
2424
pub(crate) mod float;
25-
pub use float::{PyFloat, PyFloatRef};
25+
pub use float::PyFloat;
2626
pub(crate) mod frame;
2727
pub(crate) mod function;
2828
pub use function::{PyBoundMethod, PyFunction};

wasm/lib/src/js_module.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
};
66
use js_sys::{Array, Object, Promise, Reflect};
77
use rustpython_vm::{
8-
builtins::{PyBaseExceptionRef, PyFloatRef, PyStrRef, PyType, PyTypeRef},
8+
builtins::{PyBaseExceptionRef, PyFloat, PyStrRef, PyType, PyTypeRef},
99
function::{ArgCallable, IntoPyObject, OptionalArg, OptionalOption, PosArgs},
1010
protocol::PyIterReturn,
1111
types::{IterNext, IterNextIterable},
@@ -110,7 +110,7 @@ impl PyJsValue {
110110
}
111111

112112
#[pymethod]
113-
fn new_from_float(&self, n: PyFloatRef) -> PyJsValue {
113+
fn new_from_float(&self, n: PyRef<PyFloat>) -> PyJsValue {
114114
PyJsValue::new(n.to_f64())
115115
}
116116

0 commit comments

Comments
 (0)