<s> from __future__ import division , print_function <EOL> """<STR_LIT>""" <EOL> from collections import namedtuple <EOL> from math import ceil <EOL> import numpy as np <EOL> import struct <EOL> from sys import version_info <EOL> _spec_types = ( bool , type ( None ) ) <EOL> _SPEC = <NUM_LIT> <EOL> _INT_32 = <NUM_LIT> <EOL> _FLOAT = <NUM_LIT> <EOL> _COMPLEX = <NUM_LIT> <EOL> _STR = <NUM_LIT> <EOL> _BYTES = <NUM_LIT> <EOL> _INT = <NUM_LIT> <EOL> _TUPLE = <NUM_LIT> <EOL> _NAMEDTUPLE = <NUM_LIT> <EOL> _NPARRAY = <NUM_LIT> <EOL> _LIST = <NUM_LIT> <EOL> _GETSTATE = <NUM_LIT> <EOL> _DICT = <NUM_LIT> <EOL> _INT_NEG = <NUM_LIT> <EOL> _BFSTATE = <NUM_LIT> <EOL> _VERS = <NUM_LIT> <EOL> __max_int32 = + <NUM_LIT> <EOL> __min_int32 = - <NUM_LIT> <EOL> def __int_to_bytes ( i ) : <EOL> m = <NUM_LIT> <EOL> assert i >= <NUM_LIT:0> <EOL> ba = str ( ) <EOL> while i > <NUM_LIT:0> : <EOL> b = i & m <EOL> ba += str ( bytearray ( [ b ] ) ) <EOL> i = i >> <NUM_LIT:8> <EOL> return ba [ : : - <NUM_LIT:1> ] <EOL> def __bytes_to_int ( ba ) : <EOL> i = <NUM_LIT:0> <EOL> for b in ba : <EOL> i = i << <NUM_LIT:8> <EOL> i += ord ( b ) <EOL> return i <EOL> def char_eq_byte ( ch , b ) : <EOL> return ord ( ch ) == b <EOL> def byte_eq_byte ( b1 , b2 ) : <EOL> return b1 == b2 <EOL> if version_info . major > <NUM_LIT:2> : <EOL> BIN_TYPE = bytes <EOL> str_to_bytes = lambda s : bytes ( s , '<STR_LIT:utf8>' ) <EOL> bytes_to_str = lambda b : str ( b , '<STR_LIT:utf8>' ) <EOL> LONG_TYPE = int <EOL> np_load = lambda ba : np . loads ( ba ) <EOL> init_BYTES = lambda b : bytes ( b ) <EOL> comp_id = byte_eq_byte <EOL> char_to_byte = lambda ch : ord ( ch ) <EOL> byte_to_ord = lambda b : b <EOL> else : <EOL> BIN_TYPE = str <EOL> str_to_bytes = lambda s : s <EOL> bytes_to_str = lambda b : str ( b ) <EOL> LONG_TYPE = long <EOL> np_load = lambda ba : np . loads ( str ( ba ) ) <EOL> init_BYTES = lambda b : str ( bytearray ( b ) ) <EOL> comp_id = char_eq_byte <EOL> char_to_byte = lambda ch : ch <EOL> byte_to_ord = lambda b : ord ( b ) <EOL> int_to_bytes = lambda i : i . to_bytes ( ceil ( i . bit_length ( ) / <NUM_LIT:8> ) , '<STR_LIT>' ) <EOL> bytes_to_int = lambda ba : int . from_bytes ( ba , '<STR_LIT>' ) <EOL> try : <EOL> int_to_bytes ( <NUM_LIT:2> ** <NUM_LIT> ) <EOL> except AttributeError : <EOL> int_to_bytes = __int_to_bytes <EOL> __b_tmp = int_to_bytes ( <NUM_LIT:2> ** <NUM_LIT> ) <EOL> try : <EOL> bytes_to_int ( __b_tmp ) <EOL> except AttributeError : <EOL> bytes_to_int = __bytes_to_int <EOL> assert bytes_to_int ( __b_tmp ) == <NUM_LIT:2> ** <NUM_LIT> <EOL> class BFLoadError ( Exception ) : <EOL> pass <EOL> class BFUnkownClassError ( Exception ) : <EOL> def __init__ ( self , classname ) : <EOL> Exception . __init__ ( self , "<STR_LIT>" . format ( classname ) + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> def _dump_spec ( ob ) : <EOL> if ob == True : <EOL> b = init_BYTES ( [ _SPEC , char_to_byte ( '<STR_LIT:T>' ) ] ) <EOL> elif ob == False : <EOL> b = init_BYTES ( [ _SPEC , char_to_byte ( '<STR_LIT:F>' ) ] ) <EOL> elif ob == None : <EOL> b = init_BYTES ( [ _SPEC , char_to_byte ( '<STR_LIT:N>' ) ] ) <EOL> else : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> return b <EOL> def _load_spec ( b ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _SPEC ) <EOL> if b [ <NUM_LIT:1> ] == char_to_byte ( '<STR_LIT:T>' ) : <EOL> return True , <NUM_LIT:2> <EOL> elif b [ <NUM_LIT:1> ] == char_to_byte ( '<STR_LIT:F>' ) : <EOL> return False , <NUM_LIT:2> <EOL> elif b [ <NUM_LIT:1> ] == char_to_byte ( '<STR_LIT:N>' ) : <EOL> return None , <NUM_LIT:2> <EOL> else : <EOL> raise BFLoadError ( "<STR_LIT>" . format ( b [ <NUM_LIT:1> ] ) ) <EOL> def _dump_int_32 ( ob ) : <EOL> b = init_BYTES ( [ _INT_32 ] ) <EOL> b += struct . pack ( '<STR_LIT>' , ob ) <EOL> return b <EOL> def _load_int_32 ( b ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _INT_32 ) <EOL> i = struct . unpack ( '<STR_LIT>' , b [ <NUM_LIT:1> : <NUM_LIT:5> ] ) [ <NUM_LIT:0> ] <EOL> return i , <NUM_LIT:5> <EOL> def _dump_int ( ob ) : <EOL> if ob < <NUM_LIT:0> : <EOL> b = init_BYTES ( [ _INT_NEG ] ) <EOL> ob *= - <NUM_LIT:1> <EOL> else : <EOL> b = init_BYTES ( [ _INT ] ) <EOL> ib = int_to_bytes ( ob ) <EOL> num_bytes = len ( ib ) <EOL> b += struct . pack ( '<STR_LIT>' , num_bytes ) <EOL> b += ib <EOL> return b <EOL> def _load_int ( b ) : <EOL> if comp_id ( b [ <NUM_LIT:0> ] , _INT ) : <EOL> m = <NUM_LIT:1> <EOL> elif comp_id ( b [ <NUM_LIT:0> ] , _INT_NEG ) : <EOL> m = - <NUM_LIT:1> <EOL> else : <EOL> assert False <EOL> num_bytes = struct . unpack ( '<STR_LIT>' , b [ <NUM_LIT:1> : <NUM_LIT:5> ] ) [ <NUM_LIT:0> ] <EOL> i = m * bytes_to_int ( b [ <NUM_LIT:5> : <NUM_LIT:5> + num_bytes ] ) <EOL> return i , num_bytes + <NUM_LIT:5> <EOL> def _dump_float ( ob ) : <EOL> b = init_BYTES ( [ _FLOAT ] ) <EOL> b += struct . pack ( '<STR_LIT>' , ob ) <EOL> return b <EOL> def _load_float ( b ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _FLOAT ) <EOL> f = struct . unpack ( '<STR_LIT>' , b [ <NUM_LIT:1> : <NUM_LIT:9> ] ) [ <NUM_LIT:0> ] <EOL> return f , <NUM_LIT:9> <EOL> def _dump_complex ( ob ) : <EOL> b = init_BYTES ( [ _COMPLEX ] ) <EOL> b += struct . pack ( '<STR_LIT>' , ob . real ) <EOL> b += struct . pack ( '<STR_LIT>' , ob . imag ) <EOL> return b <EOL> def _load_complex ( b ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _COMPLEX ) <EOL> re = struct . unpack ( '<STR_LIT>' , b [ <NUM_LIT:1> : <NUM_LIT:9> ] ) [ <NUM_LIT:0> ] <EOL> im = struct . unpack ( '<STR_LIT>' , b [ <NUM_LIT:9> : <NUM_LIT> ] ) [ <NUM_LIT:0> ] <EOL> return re + <NUM_LIT> * im , <NUM_LIT> <EOL> def _dump_str ( ob ) : <EOL> b = init_BYTES ( [ _STR ] ) <EOL> str_bytes = str_to_bytes ( ob ) <EOL> num_bytes = len ( str_bytes ) <EOL> b += struct . pack ( '<STR_LIT>' , num_bytes ) <EOL> b += str_bytes <EOL> return b <EOL> def _load_str ( b ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _STR ) <EOL> num_bytes = struct . unpack ( '<STR_LIT>' , b [ <NUM_LIT:1> : <NUM_LIT:5> ] ) [ <NUM_LIT:0> ] <EOL> s = bytes_to_str ( b [ <NUM_LIT:5> : <NUM_LIT:5> + num_bytes ] ) <EOL> return s , <NUM_LIT:5> + num_bytes <EOL> def _dump_bytes ( ob ) : <EOL> b = init_BYTES ( [ _BYTES ] ) <EOL> num_bytes = len ( ob ) <EOL> b += struct . pack ( '<STR_LIT>' , num_bytes ) <EOL> if isinstance ( b , str ) : <EOL> b += str ( ob ) <EOL> else : <EOL> b += ob <EOL> return b <EOL> def _load_bytes ( b ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _BYTES ) <EOL> num_bytes = struct . unpack ( '<STR_LIT>' , b [ <NUM_LIT:1> : <NUM_LIT:5> ] ) [ <NUM_LIT:0> ] <EOL> b_ = b [ <NUM_LIT:5> : <NUM_LIT:5> + num_bytes ] <EOL> return b_ , <NUM_LIT:5> + num_bytes <EOL> def _dump_tuple ( t ) : <EOL> b = init_BYTES ( [ _TUPLE ] ) <EOL> size = len ( t ) <EOL> b += struct . pack ( '<STR_LIT>' , size ) <EOL> for ti in t : <EOL> b += _dump ( ti ) <EOL> return b <EOL> def _load_tuple ( b , classes ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _TUPLE ) <EOL> size = struct . unpack ( '<STR_LIT>' , b [ <NUM_LIT:1> : <NUM_LIT:5> ] ) [ <NUM_LIT:0> ] <EOL> idx = <NUM_LIT:5> <EOL> t = [ ] <EOL> for i in range ( size ) : <EOL> ob , len_ob = _load ( b [ idx : ] , classes ) <EOL> t . append ( ob ) <EOL> idx += len_ob <EOL> return tuple ( t ) , idx <EOL> def _dump_namedtuple ( t ) : <EOL> b = init_BYTES ( [ _NAMEDTUPLE ] ) <EOL> size = len ( t ) <EOL> b += struct . pack ( '<STR_LIT>' , size ) <EOL> b += _dump ( t . __class__ . __name__ ) <EOL> for i in range ( size ) : <EOL> b += _dump ( t . _fields [ i ] ) <EOL> b += _dump ( t [ i ] ) <EOL> return b <EOL> def _load_namedtuple ( b , classes ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _NAMEDTUPLE ) <EOL> size = struct . unpack ( '<STR_LIT>' , b [ <NUM_LIT:1> : <NUM_LIT:5> ] ) [ <NUM_LIT:0> ] <EOL> class_name , len_ob = _load_str ( b [ <NUM_LIT:5> : ] ) <EOL> idx = <NUM_LIT:5> + len_ob <EOL> t = [ ] <EOL> fields = [ ] <EOL> for i in range ( size ) : <EOL> ob , len_ob = _load ( b [ idx : ] , classes ) <EOL> fields . append ( ob ) <EOL> idx += len_ob <EOL> ob , len_ob = _load ( b [ idx : ] , classes ) <EOL> t . append ( ob ) <EOL> idx += len_ob <EOL> np_class = namedtuple ( class_name , fields ) <EOL> np_obj = np_class ( * t ) <EOL> return np_obj , idx <EOL> def _dump_list ( t ) : <EOL> b = init_BYTES ( [ _LIST ] ) <EOL> size = len ( t ) <EOL> b += struct . pack ( '<STR_LIT>' , size ) <EOL> for ti in t : <EOL> b += _dump ( ti ) <EOL> return b <EOL> def _load_list ( b , classes ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _LIST ) <EOL> size = struct . unpack ( '<STR_LIT>' , b [ <NUM_LIT:1> : <NUM_LIT:5> ] ) [ <NUM_LIT:0> ] <EOL> idx = <NUM_LIT:5> <EOL> t = [ ] <EOL> for i in range ( size ) : <EOL> ob , len_ob = _load ( b [ idx : ] , classes ) <EOL> t . append ( ob ) <EOL> idx += len_ob <EOL> return t , idx <EOL> def _dump_np_array ( np_array ) : <EOL> b = init_BYTES ( [ _NPARRAY ] ) <EOL> nparray_bytes = np . ndarray . dumps ( np_array ) <EOL> size = len ( nparray_bytes ) <EOL> b += struct . pack ( '<STR_LIT>' , size ) <EOL> b += nparray_bytes <EOL> return b <EOL> def _load_np_array ( b ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _NPARRAY ) <EOL> size = struct . unpack ( '<STR_LIT>' , b [ <NUM_LIT:1> : <NUM_LIT:5> ] ) [ <NUM_LIT:0> ] <EOL> npa = np_load ( b [ <NUM_LIT:5> : size + <NUM_LIT:5> ] ) <EOL> return npa , size + <NUM_LIT:5> <EOL> def _dump_getstate ( ob ) : <EOL> b = init_BYTES ( [ _GETSTATE ] ) <EOL> state = ob . __getstate__ ( ) <EOL> obj_type = ob . __class__ . __name__ <EOL> b += _dump ( str ( obj_type ) ) <EOL> b += _dump ( state ) <EOL> return b <EOL> def _dump_bfstate ( ob ) : <EOL> b = init_BYTES ( [ _BFSTATE ] ) <EOL> state = ob . __bfstate__ ( ) <EOL> obj_type = ob . __class__ . __name__ <EOL> b += _dump ( str ( obj_type ) ) <EOL> b += _dump ( state ) <EOL> return b <EOL> def _load_getstate ( b , classes ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _GETSTATE ) <EOL> obj_type , l_obj_type = _load_str ( b [ <NUM_LIT:1> : ] ) <EOL> state , l_state = _load ( b [ l_obj_type + <NUM_LIT:1> : ] , classes ) <EOL> try : <EOL> cls = classes [ obj_type ] <EOL> except KeyError : <EOL> raise BFUnkownClassError ( obj_type ) <EOL> obj = cls . __new__ ( cls ) <EOL> obj . __setstate__ ( state ) <EOL> return obj , l_obj_type + l_state + <NUM_LIT:1> <EOL> def _dump_dict ( ob ) : <EOL> b = init_BYTES ( [ _DICT ] ) <EOL> keys = ob . keys ( ) <EOL> bin_keys = [ ] <EOL> for k in keys : <EOL> bin_keys . append ( ( _dump ( k ) , _dump ( ob [ k ] ) ) ) <EOL> b += _dump_list ( sorted ( bin_keys ) ) <EOL> return b <EOL> def _load_dict ( b , classes ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _DICT ) <EOL> sorted_keys_value , l = _load_list ( b [ <NUM_LIT:1> : ] , classes ) <EOL> res_dict = { } <EOL> for i in range ( len ( sorted_keys_value ) ) : <EOL> key = _load ( sorted_keys_value [ i ] [ <NUM_LIT:0> ] , classes ) [ <NUM_LIT:0> ] <EOL> value = _load ( sorted_keys_value [ i ] [ <NUM_LIT:1> ] , classes ) [ <NUM_LIT:0> ] <EOL> res_dict [ key ] = value <EOL> return res_dict , l + <NUM_LIT:1> <EOL> def _dump ( ob ) : <EOL> if isinstance ( ob , _spec_types ) : <EOL> return _dump_spec ( ob ) <EOL> elif isinstance ( ob , ( int , LONG_TYPE ) ) : <EOL> if ( __min_int32 <= ob ) and ( ob <= __max_int32 ) : <EOL> return _dump_int_32 ( ob ) <EOL> else : <EOL> return _dump_int ( ob ) <EOL> elif isinstance ( ob , float ) : <EOL> return _dump_float ( ob ) <EOL> elif isinstance ( ob , complex ) : <EOL> return _dump_complex ( ob ) <EOL> elif isinstance ( ob , str ) : <EOL> return _dump_str ( ob ) <EOL> elif isinstance ( ob , bytes ) : <EOL> return _dump_bytes ( ob ) <EOL> elif isinstance ( ob , tuple ) : <EOL> if hasattr ( ob , '<STR_LIT>' ) : <EOL> return _dump_namedtuple ( ob ) <EOL> else : <EOL> return _dump_tuple ( ob ) <EOL> elif isinstance ( ob , list ) : <EOL> return _dump_list ( ob ) <EOL> elif isinstance ( ob , np . ndarray ) : <EOL> return _dump_np_array ( ob ) <EOL> elif isinstance ( ob , dict ) : <EOL> return _dump_dict ( ob ) <EOL> elif hasattr ( ob , '<STR_LIT>' ) : <EOL> return _dump_getstate ( ob ) <EOL> elif hasattr ( ob , '<STR_LIT>' ) : <EOL> return _dump_bfstate ( ob ) <EOL> else : <EOL> raise RuntimeError ( "<STR_LIT>" . format ( type ( ob ) ) ) <EOL> def _load ( b , classes ) : <EOL> identifier = b [ <NUM_LIT:0> ] <EOL> if isinstance ( identifier , str ) : <EOL> identifier = ord ( identifier ) <EOL> if identifier == _SPEC : <EOL> return _load_spec ( b ) <EOL> elif identifier == _INT_32 : <EOL> return _load_int_32 ( b ) <EOL> elif ( identifier == _INT ) or ( identifier == _INT_NEG ) : <EOL> return _load_int ( b ) <EOL> elif identifier == _FLOAT : <EOL> return _load_float ( b ) <EOL> elif identifier == _COMPLEX : <EOL> return _load_complex ( b ) <EOL> elif identifier == _STR : <EOL> return _load_str ( b ) <EOL> elif identifier == _BYTES : <EOL> return _load_bytes ( b ) <EOL> elif identifier == _TUPLE : <EOL> return _load_tuple ( b , classes ) <EOL> elif identifier == _NAMEDTUPLE : <EOL> return _load_namedtuple ( b , classes ) <EOL> elif identifier == _LIST : <EOL> return _load_list ( b , classes ) <EOL> elif identifier == _NPARRAY : <EOL> return _load_np_array ( b ) <EOL> elif identifier == _DICT : <EOL> return _load_dict ( b , classes ) <EOL> elif identifier == _GETSTATE : <EOL> return _load_getstate ( b , classes ) <EOL> elif identifier == _BFSTATE : <EOL> raise BFLoadError ( "<STR_LIT>" ) <EOL> else : <EOL> raise BFLoadError ( "<STR_LIT>" . format ( hex ( identifier ) ) ) <EOL> def dump ( ob , vers = _VERS ) : <EOL> """<STR_LIT>""" <EOL> global _dump <EOL> if vers == _VERS : <EOL> return init_BYTES ( [ _VERS ] ) + _dump ( ob ) <EOL> elif vers < <NUM_LIT> : <EOL> __dump_tmp = _dump <EOL> _dump = _dump_00 <EOL> try : <EOL> res = _dump ( ob ) <EOL> finally : <EOL> _dump = __dump_tmp <EOL> return res <EOL> def load ( b , classes = { } ) : <EOL> """<STR_LIT>""" <EOL> global _load <EOL> vers = b [ <NUM_LIT:0> ] <EOL> if byte_to_ord ( vers ) == _VERS : <EOL> return _load ( b [ <NUM_LIT:1> : ] , classes ) [ <NUM_LIT:0> ] <EOL> elif byte_to_ord ( vers ) < <NUM_LIT> : <EOL> __load_tmp = _load <EOL> _load = _load_00 <EOL> try : <EOL> res = _load ( b , classes ) [ <NUM_LIT:0> ] <EOL> finally : <EOL> _load = __load_tmp <EOL> return res <EOL> else : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> def _load_namedtuple_00 ( b , classes ) : <EOL> assert comp_id ( b [ <NUM_LIT:0> ] , _NAMEDTUPLE ) <EOL> size = struct . unpack ( '<STR_LIT>' , b [ <NUM_LIT:1> : <NUM_LIT:5> ] ) [ <NUM_LIT:0> ] <EOL> class_name , len_ob = _load_str ( b [ <NUM_LIT:5> : ] ) <EOL> idx = <NUM_LIT:5> + len_ob <EOL> t = [ ] <EOL> for i in range ( size ) : <EOL> ob , len_ob = _load ( b [ idx : ] , classes ) <EOL> t . append ( ob ) <EOL> idx += len_ob <EOL> try : <EOL> np_class = classes [ class_name ] <EOL> except KeyError : <EOL> raise BFUnkownClassError ( class_name ) <EOL> obj = np_class ( * t ) <EOL> return obj , idx <EOL> def _dump_namedtuple_00 ( t ) : <EOL> b = init_BYTES ( [ _NAMEDTUPLE ] ) <EOL> size = len ( t ) <EOL> b += struct . pack ( '<STR_LIT>' , size ) <EOL> b += _dump ( t . __class__ . __name__ ) <EOL> for ti in t : <EOL> b += _dump ( ti ) <EOL> return b <EOL> def _load_00 ( b , classes ) : <EOL> identifier = b [ <NUM_LIT:0> ] <EOL> if isinstance ( identifier , str ) : <EOL> identifier = ord ( identifier ) <EOL> if identifier == _SPEC : <EOL> return _load_spec ( b ) <EOL> elif identifier == _INT_32 : <EOL> return _load_int_32 ( b ) <EOL> elif ( identifier == _INT ) or ( identifier == _INT_NEG ) : <EOL> return _load_int ( b ) <EOL> elif identifier == _FLOAT : <EOL> return _load_float ( b ) <EOL> elif identifier == _COMPLEX : <EOL> return _load_complex ( b ) <EOL> elif identifier == _STR : <EOL> return _load_str ( b ) <EOL> elif identifier == _BYTES : <EOL> return _load_bytes ( b ) <EOL> elif identifier == _TUPLE : <EOL> return _load_tuple ( b , classes ) <EOL> elif identifier == _NAMEDTUPLE : <EOL> return _load_namedtuple_00 ( b , classes ) <EOL> elif identifier == _LIST : <EOL> return _load_list ( b , classes ) <EOL> elif identifier == _NPARRAY : <EOL> return _load_np_array ( b ) <EOL> elif identifier == _DICT : <EOL> return _load_dict ( b , classes ) <EOL> elif identifier == _GETSTATE : <EOL> return _load_getstate ( b , classes ) <EOL> else : <EOL> raise BFLoadError ( "<STR_LIT>" . format ( hex ( identifier ) ) ) <EOL> def _dump_00 ( ob ) : <EOL> if isinstance ( ob , _spec_types ) : <EOL> return _dump_spec ( ob ) <EOL> elif isinstance ( ob , ( int , LONG_TYPE ) ) : <EOL> if ( __min_int32 <= ob ) and ( ob <= __max_int32 ) : <EOL> return _dump_int_32 ( ob ) <EOL> else : <EOL> return _dump_int ( ob ) <EOL> elif isinstance ( ob , float ) : <EOL> return _dump_float ( ob ) <EOL> elif isinstance ( ob , complex ) : <EOL> return _dump_complex ( ob ) <EOL> elif isinstance ( ob , str ) : <EOL> return _dump_str ( ob ) <EOL> elif isinstance ( ob , bytes ) : <EOL> return _dump_bytes ( ob ) <EOL> elif isinstance ( ob , tuple ) : <EOL> if hasattr ( ob , '<STR_LIT>' ) : <EOL> return _dump_namedtuple_00 ( ob ) <EOL> else : <EOL> return _dump_tuple ( ob ) <EOL> elif isinstance ( ob , list ) : <EOL> return _dump_list ( ob ) <EOL> elif isinstance ( ob , np . ndarray ) : <EOL> return _dump_np_array ( ob ) <EOL> elif isinstance ( ob , dict ) : <EOL> return _dump_dict ( ob ) <EOL> elif hasattr ( ob , '<STR_LIT>' ) : <EOL> return _dump_getstate ( ob ) <EOL> else : <EOL> raise RuntimeError ( "<STR_LIT>" . format ( type ( ob ) ) ) </s>
