Skip to content

Commit 112aff6

Browse files
committed
remove unsed slots
1 parent a03d228 commit 112aff6

File tree

4 files changed

+9
-463
lines changed

4 files changed

+9
-463
lines changed

crates/vm/src/builtins/bool.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ impl PyBool {
126126
.and_then(|format_spec| format_spec.format_bool(new_bool))
127127
.map_err(|err| err.into_pyexception(vm))
128128
}
129+
}
129130

130-
#[pymethod(name = "__ror__")]
131-
#[pymethod]
132-
fn __or__(lhs: PyObjectRef, rhs: PyObjectRef, vm: &VirtualMachine) -> PyObjectRef {
131+
impl PyBool {
132+
pub(crate) fn __or__(lhs: PyObjectRef, rhs: PyObjectRef, vm: &VirtualMachine) -> PyObjectRef {
133133
if lhs.fast_isinstance(vm.ctx.types.bool_type)
134134
&& rhs.fast_isinstance(vm.ctx.types.bool_type)
135135
{
@@ -143,9 +143,7 @@ impl PyBool {
143143
}
144144
}
145145

146-
#[pymethod(name = "__rand__")]
147-
#[pymethod]
148-
fn __and__(lhs: PyObjectRef, rhs: PyObjectRef, vm: &VirtualMachine) -> PyObjectRef {
146+
pub(crate) fn __and__(lhs: PyObjectRef, rhs: PyObjectRef, vm: &VirtualMachine) -> PyObjectRef {
149147
if lhs.fast_isinstance(vm.ctx.types.bool_type)
150148
&& rhs.fast_isinstance(vm.ctx.types.bool_type)
151149
{
@@ -159,9 +157,7 @@ impl PyBool {
159157
}
160158
}
161159

162-
#[pymethod(name = "__rxor__")]
163-
#[pymethod]
164-
fn __xor__(lhs: PyObjectRef, rhs: PyObjectRef, vm: &VirtualMachine) -> PyObjectRef {
160+
pub(crate) fn __xor__(lhs: PyObjectRef, rhs: PyObjectRef, vm: &VirtualMachine) -> PyObjectRef {
165161
if lhs.fast_isinstance(vm.ctx.types.bool_type)
166162
&& rhs.fast_isinstance(vm.ctx.types.bool_type)
167163
{

crates/vm/src/builtins/complex.rs

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -264,133 +264,11 @@ impl PyComplex {
264264
self.value.im
265265
}
266266

267-
#[pymethod]
268-
fn __abs__(&self, vm: &VirtualMachine) -> PyResult<f64> {
269-
let Complex64 { im, re } = self.value;
270-
let is_finite = im.is_finite() && re.is_finite();
271-
let abs_result = re.hypot(im);
272-
if is_finite && abs_result.is_infinite() {
273-
Err(vm.new_overflow_error("absolute value too large"))
274-
} else {
275-
Ok(abs_result)
276-
}
277-
}
278-
279-
#[inline]
280-
fn op<F>(
281-
&self,
282-
other: PyObjectRef,
283-
op: F,
284-
vm: &VirtualMachine,
285-
) -> PyResult<PyArithmeticValue<Complex64>>
286-
where
287-
F: Fn(Complex64, Complex64) -> PyResult<Complex64>,
288-
{
289-
to_op_complex(&other, vm)?.map_or_else(
290-
|| Ok(NotImplemented),
291-
|other| Ok(Implemented(op(self.value, other)?)),
292-
)
293-
}
294-
295-
#[pymethod(name = "__radd__")]
296-
#[pymethod]
297-
fn __add__(
298-
&self,
299-
other: PyObjectRef,
300-
vm: &VirtualMachine,
301-
) -> PyResult<PyArithmeticValue<Complex64>> {
302-
self.op(other, |a, b| Ok(a + b), vm)
303-
}
304-
305-
#[pymethod]
306-
fn __sub__(
307-
&self,
308-
other: PyObjectRef,
309-
vm: &VirtualMachine,
310-
) -> PyResult<PyArithmeticValue<Complex64>> {
311-
self.op(other, |a, b| Ok(a - b), vm)
312-
}
313-
314-
#[pymethod]
315-
fn __rsub__(
316-
&self,
317-
other: PyObjectRef,
318-
vm: &VirtualMachine,
319-
) -> PyResult<PyArithmeticValue<Complex64>> {
320-
self.op(other, |a, b| Ok(b - a), vm)
321-
}
322-
323267
#[pymethod]
324268
fn conjugate(&self) -> Complex64 {
325269
self.value.conj()
326270
}
327271

328-
#[pymethod(name = "__rmul__")]
329-
#[pymethod]
330-
fn __mul__(
331-
&self,
332-
other: PyObjectRef,
333-
vm: &VirtualMachine,
334-
) -> PyResult<PyArithmeticValue<Complex64>> {
335-
self.op(other, |a, b| Ok(a * b), vm)
336-
}
337-
338-
#[pymethod]
339-
fn __truediv__(
340-
&self,
341-
other: PyObjectRef,
342-
vm: &VirtualMachine,
343-
) -> PyResult<PyArithmeticValue<Complex64>> {
344-
self.op(other, |a, b| inner_div(a, b, vm), vm)
345-
}
346-
347-
#[pymethod]
348-
fn __rtruediv__(
349-
&self,
350-
other: PyObjectRef,
351-
vm: &VirtualMachine,
352-
) -> PyResult<PyArithmeticValue<Complex64>> {
353-
self.op(other, |a, b| inner_div(b, a, vm), vm)
354-
}
355-
356-
#[pymethod]
357-
const fn __pos__(&self) -> Complex64 {
358-
self.value
359-
}
360-
361-
#[pymethod]
362-
fn __neg__(&self) -> Complex64 {
363-
-self.value
364-
}
365-
366-
#[pymethod]
367-
fn __pow__(
368-
&self,
369-
other: PyObjectRef,
370-
mod_val: OptionalOption<PyObjectRef>,
371-
vm: &VirtualMachine,
372-
) -> PyResult<PyArithmeticValue<Complex64>> {
373-
if mod_val.flatten().is_some() {
374-
Err(vm.new_value_error("complex modulo not allowed"))
375-
} else {
376-
self.op(other, |a, b| inner_pow(a, b, vm), vm)
377-
}
378-
}
379-
380-
#[pymethod]
381-
fn __rpow__(
382-
&self,
383-
other: PyObjectRef,
384-
vm: &VirtualMachine,
385-
) -> PyResult<PyArithmeticValue<Complex64>> {
386-
self.op(other, |a, b| inner_pow(b, a, vm), vm)
387-
}
388-
389-
#[pymethod]
390-
fn __bool__(&self) -> bool {
391-
!Complex64::is_zero(&self.value)
392-
}
393-
394272
#[pymethod]
395273
const fn __getnewargs__(&self) -> (f64, f64) {
396274
let Complex64 { re, im } = self.value;

crates/vm/src/builtins/float.rs

Lines changed: 0 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -238,182 +238,6 @@ impl PyFloat {
238238
.to_owned())
239239
}
240240

241-
#[pymethod]
242-
const fn __abs__(&self) -> f64 {
243-
self.value.abs()
244-
}
245-
246-
#[inline]
247-
fn simple_op<F>(
248-
&self,
249-
other: PyObjectRef,
250-
op: F,
251-
vm: &VirtualMachine,
252-
) -> PyResult<PyArithmeticValue<f64>>
253-
where
254-
F: Fn(f64, f64) -> PyResult<f64>,
255-
{
256-
to_op_float(&other, vm)?.map_or_else(
257-
|| Ok(NotImplemented),
258-
|other| Ok(Implemented(op(self.value, other)?)),
259-
)
260-
}
261-
262-
#[inline]
263-
fn complex_op<F>(&self, other: PyObjectRef, op: F, vm: &VirtualMachine) -> PyResult
264-
where
265-
F: Fn(f64, f64) -> PyResult,
266-
{
267-
to_op_float(&other, vm)?.map_or_else(
268-
|| Ok(vm.ctx.not_implemented()),
269-
|other| op(self.value, other),
270-
)
271-
}
272-
273-
#[inline]
274-
fn tuple_op<F>(
275-
&self,
276-
other: PyObjectRef,
277-
op: F,
278-
vm: &VirtualMachine,
279-
) -> PyResult<PyArithmeticValue<(f64, f64)>>
280-
where
281-
F: Fn(f64, f64) -> PyResult<(f64, f64)>,
282-
{
283-
to_op_float(&other, vm)?.map_or_else(
284-
|| Ok(NotImplemented),
285-
|other| Ok(Implemented(op(self.value, other)?)),
286-
)
287-
}
288-
289-
#[pymethod(name = "__radd__")]
290-
#[pymethod]
291-
fn __add__(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyArithmeticValue<f64>> {
292-
self.simple_op(other, |a, b| Ok(a + b), vm)
293-
}
294-
295-
#[pymethod]
296-
const fn __bool__(&self) -> bool {
297-
self.value != 0.0
298-
}
299-
300-
#[pymethod]
301-
fn __divmod__(
302-
&self,
303-
other: PyObjectRef,
304-
vm: &VirtualMachine,
305-
) -> PyResult<PyArithmeticValue<(f64, f64)>> {
306-
self.tuple_op(other, |a, b| inner_divmod(a, b, vm), vm)
307-
}
308-
309-
#[pymethod]
310-
fn __rdivmod__(
311-
&self,
312-
other: PyObjectRef,
313-
vm: &VirtualMachine,
314-
) -> PyResult<PyArithmeticValue<(f64, f64)>> {
315-
self.tuple_op(other, |a, b| inner_divmod(b, a, vm), vm)
316-
}
317-
318-
#[pymethod]
319-
fn __floordiv__(
320-
&self,
321-
other: PyObjectRef,
322-
vm: &VirtualMachine,
323-
) -> PyResult<PyArithmeticValue<f64>> {
324-
self.simple_op(other, |a, b| inner_floordiv(a, b, vm), vm)
325-
}
326-
327-
#[pymethod]
328-
fn __rfloordiv__(
329-
&self,
330-
other: PyObjectRef,
331-
vm: &VirtualMachine,
332-
) -> PyResult<PyArithmeticValue<f64>> {
333-
self.simple_op(other, |a, b| inner_floordiv(b, a, vm), vm)
334-
}
335-
336-
#[pymethod(name = "__mod__")]
337-
fn mod_(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyArithmeticValue<f64>> {
338-
self.simple_op(other, |a, b| inner_mod(a, b, vm), vm)
339-
}
340-
341-
#[pymethod]
342-
fn __rmod__(
343-
&self,
344-
other: PyObjectRef,
345-
vm: &VirtualMachine,
346-
) -> PyResult<PyArithmeticValue<f64>> {
347-
self.simple_op(other, |a, b| inner_mod(b, a, vm), vm)
348-
}
349-
350-
#[pymethod]
351-
const fn __pos__(&self) -> f64 {
352-
self.value
353-
}
354-
355-
#[pymethod]
356-
const fn __neg__(&self) -> f64 {
357-
-self.value
358-
}
359-
360-
#[pymethod]
361-
fn __pow__(
362-
&self,
363-
other: PyObjectRef,
364-
mod_val: OptionalOption<PyObjectRef>,
365-
vm: &VirtualMachine,
366-
) -> PyResult {
367-
if mod_val.flatten().is_some() {
368-
Err(vm.new_type_error("floating point pow() does not accept a 3rd argument"))
369-
} else {
370-
self.complex_op(other, |a, b| float_pow(a, b, vm), vm)
371-
}
372-
}
373-
374-
#[pymethod]
375-
fn __rpow__(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
376-
self.complex_op(other, |a, b| float_pow(b, a, vm), vm)
377-
}
378-
379-
#[pymethod]
380-
fn __sub__(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyArithmeticValue<f64>> {
381-
self.simple_op(other, |a, b| Ok(a - b), vm)
382-
}
383-
384-
#[pymethod]
385-
fn __rsub__(
386-
&self,
387-
other: PyObjectRef,
388-
vm: &VirtualMachine,
389-
) -> PyResult<PyArithmeticValue<f64>> {
390-
self.simple_op(other, |a, b| Ok(b - a), vm)
391-
}
392-
393-
#[pymethod]
394-
fn __truediv__(
395-
&self,
396-
other: PyObjectRef,
397-
vm: &VirtualMachine,
398-
) -> PyResult<PyArithmeticValue<f64>> {
399-
self.simple_op(other, |a, b| inner_div(a, b, vm), vm)
400-
}
401-
402-
#[pymethod]
403-
fn __rtruediv__(
404-
&self,
405-
other: PyObjectRef,
406-
vm: &VirtualMachine,
407-
) -> PyResult<PyArithmeticValue<f64>> {
408-
self.simple_op(other, |a, b| inner_div(b, a, vm), vm)
409-
}
410-
411-
#[pymethod(name = "__rmul__")]
412-
#[pymethod]
413-
fn __mul__(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyArithmeticValue<f64>> {
414-
self.simple_op(other, |a, b| Ok(a * b), vm)
415-
}
416-
417241
#[pymethod]
418242
fn __trunc__(&self, vm: &VirtualMachine) -> PyResult<BigInt> {
419243
try_to_bigint(self.value, vm)
@@ -459,16 +283,6 @@ impl PyFloat {
459283
Ok(value)
460284
}
461285

462-
#[pymethod]
463-
fn __int__(&self, vm: &VirtualMachine) -> PyResult<BigInt> {
464-
self.__trunc__(vm)
465-
}
466-
467-
#[pymethod]
468-
const fn __float__(zelf: PyRef<Self>) -> PyRef<Self> {
469-
zelf
470-
}
471-
472286
#[pygetset]
473287
const fn real(zelf: PyRef<Self>) -> PyRef<Self> {
474288
zelf

0 commit comments

Comments
 (0)