https://github.com/adsharma/py2many/pull/254 implements some of this. Before transpiling, if we detect such overflows the transpiler errors out instead of relying on the target language compiler to report it.TODO: Do something similar for underflows.-ArunOn Wed, May 19, 2021 at 3:04 PM Arun Sharma <arun@sharma-home.net> wrote:On Wed, May 19, 2021 at 2:37 PM Guido van Rossum <guido@python.org> wrote:How well would something like this solve your issue?import typingif typing.TYPE_CHECKING:class i8(int): passelse:from ctypes import c_int8 as i8This approach has the benefit of avoiding a common problem with the c_int8 approach.a: i8 = i8(1)b: i8 = i8(2)>> a + b
TypeError: unsupported operand type(s) for +: 'c_byte' and 'c_byte'I generally like it (as long as they're builtin/ergonomic and end users don't have to write the imports). But code such as:a: i8 = 1b: i8 = 2c: int = a + bgenerate errors that I would like to see go awayOr perhaps instead of the class definition use a type alias:i8 = inta: i8 = 10
b: i16 = 20
a = b # should generate an error but doesn't.-Arun