def __new__(cls, arg, size): """Create an ExprInt from a modint or num/size @arg: 'intable' number @size: int size""" # if is_modint(arg): # assert size == arg.size # Avoid a common blunder # assert not isinstance(arg, ExprInt) # Ensure arg is always a moduint arg = int(arg) if size not in mod_size2uint: define_uint(size) arg = mod_size2uint[size](arg) # Get the Singleton instance expr = Expr.get_object(cls, (arg, size)) # Save parameters (__init__ is called with parameters unchanged) expr._arg = arg return expr
def __new__(cls, arg, size): """Create an ExprInt from a modint or num/size @arg: 'intable' number @size: int size""" if is_modint(arg): assert size == arg.size # Avoid a common blunder assert not isinstance(arg, ExprInt) # Ensure arg is always a moduint arg = int(arg) if size not in mod_size2uint: define_uint(size) arg = mod_size2uint[size](arg) # Get the Singleton instance expr = Expr.get_object(cls, (arg, size)) # Save parameters (__init__ is called with parameters unchanged) expr.__arg = arg expr.__size = expr.__arg.size return expr