diff --git a/src/pystencils/nbackend/jit/cpu_extension_module.py b/src/pystencils/nbackend/jit/cpu_extension_module.py index 3b67fa45f9bb4888f9ef761a57d3f5be6d485edb..1859ec661b150753124c26ba83c1b0d828f5780c 100644 --- a/src/pystencils/nbackend/jit/cpu_extension_module.py +++ b/src/pystencils/nbackend/jit/cpu_extension_module.py @@ -199,7 +199,7 @@ if( !kwargs || !PyDict_Check(kwargs) ) {{ f"Don't know how to cast Python objects to {dtype}" ) - def _type_char(self, dtype: PsScalarType) -> str | None: + def _type_char(self, dtype: PsAbstractType) -> str | None: if isinstance( dtype, (PsUnsignedIntegerType, PsSignedIntegerType, PsIeeeFloatType) ): diff --git a/src/pystencils/nbackend/types/basic_types.py b/src/pystencils/nbackend/types/basic_types.py index a2b2196588bf500fa5178dbe808e834b8da6df5c..ad123148ed584e7995dc03043f9caa877e99cc55 100644 --- a/src/pystencils/nbackend/types/basic_types.py +++ b/src/pystencils/nbackend/types/basic_types.py @@ -40,6 +40,11 @@ class PsAbstractType(ABC): def required_headers(self) -> set[str]: """The set of header files required when this type occurs in generated code.""" return set() + + @property + def itemsize(self) -> int | None: + """If this type has a valid in-memory size, return that size.""" + return None # ------------------------------------------------------------------------------------------- # Internal virtual operations @@ -203,11 +208,6 @@ class PsScalarType(PsNumericType, ABC): def is_float(self) -> bool: return isinstance(self, PsIeeeFloatType) - @property - @abstractmethod - def itemsize(self) -> int: - """Size of this type's elements in bytes.""" - class PsIntegerType(PsScalarType, ABC): """Class to model signed and unsigned integer types.