<s> import sys <EOL> PY3 = sys . version_info [ <NUM_LIT:0> ] == <NUM_LIT:3> <EOL> class LazySlicingIterable ( object ) : <EOL> def __init__ ( self , length_getter , items_getter ) : <EOL> self . length_getter = length_getter <EOL> self . items_getter = items_getter <EOL> def __len__ ( self ) : <EOL> return self . length_getter ( ) <EOL> def __getitem__ ( self , k ) : <EOL> if isinstance ( k , int ) : <EOL> return self . items_getter ( k , k ) <EOL> elif isinstance ( k , slice ) : <EOL> if k . step : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> return self . items_getter ( k . start , k . stop ) <EOL> else : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> class cached_property ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , fget = None , fset = None , fdel = None , doc = None ) : <EOL> self . __get = fget <EOL> self . __set = fset <EOL> self . __del = fdel <EOL> self . __doc__ = doc or fget . __doc__ <EOL> self . __name__ = fget . __name__ <EOL> self . __module__ = fget . __module__ <EOL> def __get__ ( self , obj , type = None ) : <EOL> if obj is None : <EOL> return self <EOL> try : <EOL> return obj . __dict__ [ self . __name__ ] <EOL> except KeyError : <EOL> value = obj . __dict__ [ self . __name__ ] = self . __get ( obj ) <EOL> return value <EOL> def __set__ ( self , obj , value ) : <EOL> if obj is None : <EOL> return self <EOL> if self . __set is not None : <EOL> value = self . __set ( obj , value ) <EOL> obj . __dict__ [ self . __name__ ] = value <EOL> def __delete__ ( self , obj ) : <EOL> if obj is None : <EOL> return self <EOL> try : <EOL> value = obj . __dict__ . pop ( self . __name__ ) <EOL> except KeyError : <EOL> pass <EOL> else : <EOL> if self . __del is not None : <EOL> self . __del ( obj , value ) <EOL> def setter ( self , fset ) : <EOL> return self . __class__ ( self . __get , fset , self . __del ) <EOL> def deleter ( self , fdel ) : <EOL> return self . __class__ ( self . __get , self . __set , fdel ) </s>
