We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 09710b5 commit 1c814ffCopy full SHA for 1c814ff
tests/snippets/floats.py
@@ -137,6 +137,7 @@
137
138
assert 1.2 ** 2 == 1.44
139
assert_raises(OverflowError, lambda: 1.2 ** (10 ** 1000))
140
+assert 3 ** 2.0 == 9.0
141
142
assert (1.7).real == 1.7
143
assert (1.3).is_integer() == False
vm/src/obj/objfloat.rs
@@ -284,6 +284,14 @@ impl PyFloat {
284
)
285
}
286
287
+ #[pymethod(name = "__rpow__")]
288
+ fn rpow(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
289
+ try_float(&other, vm)?.map_or_else(
290
+ || Ok(vm.ctx.not_implemented()),
291
+ |other| other.powf(self.value).into_pyobject(vm),
292
+ )
293
+ }
294
+
295
#[pymethod(name = "__sub__")]
296
fn sub(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
297
try_float(&other, vm)?.map_or_else(
0 commit comments