From 9f77ef5642cd5d61e69ad215847c8886c84560b0 Mon Sep 17 00:00:00 2001 From: Nicolas Kruse Date: Mon, 1 Dec 2025 16:44:49 +0100 Subject: [PATCH] optimization for float/int operations added --- src/copapy/_basic_types.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/copapy/_basic_types.py b/src/copapy/_basic_types.py index 5170d04..99ee92c 100644 --- a/src/copapy/_basic_types.py +++ b/src/copapy/_basic_types.py @@ -163,6 +163,8 @@ class variable(Generic[TNum], Net): @overload def __mul__(self, other: TVarNumb) -> 'variable[float] | variable[int]': ... 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) @overload