def dehydrate(self, values):
def dehydrate_(obj):<EOL><INDENT>try:<EOL><INDENT>f = self.dehydration_functions[type(obj)]<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>return f(obj)<EOL><DEDENT>if obj is None:<EOL><INDENT>return None<EOL><DEDENT>elif isinstance(obj, bool):<EOL><INDENT>return obj<EOL><DEDENT>elif isinstance(obj, int):<EOL><INDENT>if INT64_MIN <= obj <= INT64_MAX:<EOL><INDENT>return obj<EOL><DEDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>elif isinstance(obj, float):<EOL><INDENT>return obj<EOL><DEDENT>elif isinstance(obj, str):<EOL><INDENT>return obj<EOL><DEDENT>elif isinstance(obj, (bytes, bytearray)):  <EOL><INDENT>if self.supports_bytes:<EOL><INDENT>return obj<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT><DEDENT>elif isinstance(obj, (list, map_type)):<EOL><INDENT>return list(map(dehydrate_, obj))<EOL><DEDENT>elif isinstance(obj, dict):<EOL><INDENT>if any(not isinstance(key, str) for key in obj.keys()):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>return {key: dehydrate_(value) for key, value in obj.items()}<EOL><DEDENT>else:<EOL><INDENT>raise TypeError(obj)<EOL><DEDENT><DEDENT>return tuple(map(dehydrate_, values))<EOL>
Convert native values into PackStream values.