from collections import Iterable
+import functools
+import warnings
-__all__ = ["flatten", "union", "log2_int", "bits_for"]
+__all__ = ["flatten", "union", "log2_int", "bits_for", "deprecated"]
def flatten(i):
if require_sign_bit:
r += 1
return r
+
+
+def deprecated(message, stacklevel=2):
+ def decorator(f):
+ @functools.wraps(f)
+ def wrapper(*args, **kwargs):
+ warnings.warn(message, DeprecationWarning, stacklevel=stacklevel)
+ return f(*args, **kwargs)
+ return wrapper
+ return decorator