optimization for float/int operations added

This commit is contained in:
Nicolas Kruse 2025-12-01 16:44:49 +01:00
parent 8fe51a2e45
commit 9f77ef5642
1 changed files with 2 additions and 0 deletions

View File

@ -163,6 +163,8 @@ class variable(Generic[TNum], Net):
@overload @overload
def __mul__(self, other: TVarNumb) -> 'variable[float] | variable[int]': ... def __mul__(self, other: TVarNumb) -> 'variable[float] | variable[int]': ...
def __mul__(self, other: TVarNumb) -> Any: def __mul__(self, other: TVarNumb) -> Any:
if self.dtype == 'float' and isinstance(other, int):
other = float(other) # Prevent runtime conversion of consts; TODO: add this for other operations
return add_op('mul', [self, other], True) return add_op('mul', [self, other], True)
@overload @overload