



import math
from timeit import timeit


def 		_UpperCAmelCase    (				snake_case      ):





					"""simple docstring"""

					_lowerCAmelCase      =   0
					_lowerCAmelCase      =   abs(snake_case      )
					while True:
										_lowerCAmelCase      =   n // 10
										digits += 1
										if n == 0:
															break
					return digits


def 		_UpperCAmelCase    (				snake_case      ):





					"""simple docstring"""

					return 1 if n == 0 else math.floor(math.log(abs(snake_case      )     ,						10      ) + 1      )


def 		_UpperCAmelCase    (				snake_case      ):





					"""simple docstring"""

					return len(str(abs(snake_case      )      )      )


def 		_UpperCAmelCase    (				):





					"""simple docstring"""

					from collections.abc import Callable

					def benchmark_a_function(snake_case     ,						snake_case      ) -> None:
										_lowerCAmelCase      =   F'{func.__name__}({value})'
										_lowerCAmelCase      =   timeit(F'__main__.{call}'     ,						setup="""import __main__"""      )
										print(F'{call}: {func(snake_case      )} -- {timing} seconds'      )

					for value in (26_21_44, 11_25_89_99_06_84_26_24, 1_26_76_50_60_02_28_22_94_01_49_67_03_20_53_76):
										for func in (num_digits, num_digits_fast, num_digits_faster):
															benchmark_a_function(snake_case     ,						snake_case      )
										print()


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	benchmark()








# Lint as: python3

import hashlib
from typing import Union


def 		_UpperCAmelCase    (				snake_case      ):





					"""simple docstring"""

					if isinstance(snake_case     ,						snake_case      ):
										# Data already in bytes, returns as it as
										return hash_data
					elif isinstance(snake_case     ,						snake_case      ):
										# We keep the data as it as for it ot be later encoded to UTF-8
										# However replace `\\` with `/` for Windows compatibility
										_lowerCAmelCase      =   hash_data.replace("""\\"""     ,						"""/"""      )
					elif isinstance(snake_case     ,						snake_case      ):
										_lowerCAmelCase      =   str(snake_case      )
					else:
										# If data is not of the required type, raise error
										raise InvalidKeyError(snake_case      )

					return hash_data.encode("""utf-8"""      )





class  __lowerCAmelCase			(					lowerCamelCase__	):




				def __init__(							self						,    _snake_case		):



									"""simple docstring"""





									_lowerCAmelCase      =   """\nFAILURE TO GENERATE DATASET: Invalid key type detected"""
									_lowerCAmelCase      =   F'\nFound Key {hash_data} of type {type(_snake_case		)}'
									_lowerCAmelCase      =   """\nKeys should be either str, int or bytes type"""
									super().__init__(F'{self.prefix}{self.err_msg}{self.suffix}'		)





class  __lowerCAmelCase			(					lowerCamelCase__	):




				def __init__(							self						,    _snake_case						,    _snake_case						,    _snake_case=""		):



									"""simple docstring"""





									_lowerCAmelCase      =   key
									_lowerCAmelCase      =   duplicate_key_indices
									_lowerCAmelCase      =   fix_msg
									_lowerCAmelCase      =   """Found multiple examples generated with the same key"""
									if len(_snake_case		) <= 20:
														_lowerCAmelCase      =   F'\nThe examples at index {", ".join(_snake_case		)} have the key {key}'
									else:
														_lowerCAmelCase      =   F'\nThe examples at index {", ".join(duplicate_key_indices[:20]		)}... ({len(_snake_case		) - 20} more) have the key {key}'
									_lowerCAmelCase      =   """\n""" + fix_msg if fix_msg else """"""
									super().__init__(F'{self.prefix}{self.err_msg}{self.suffix}'		)





class  __lowerCAmelCase			:




				def __init__(							self						,    _snake_case		):



									"""simple docstring"""





									_lowerCAmelCase      =   hashlib.mda(_as_bytes(_snake_case		)		)




				def 							snake_case       (							self						,    _snake_case		):



									"""simple docstring"""





									_lowerCAmelCase      =   self._split_mda.copy()
									_lowerCAmelCase      =   _as_bytes(_snake_case		)
									mda.update(_snake_case		)
									# Convert to integer with hexadecimal conversion
									return int(mda.hexdigest()						,    16		)



