<s> from functools import partial <EOL> import pytest <EOL> empty = object ( ) <EOL> class cached_property ( object ) : <EOL> def __init__ ( self , func ) : <EOL> self . func = func <EOL> def __get__ ( self , obj , cls ) : <EOL> value = obj . __dict__ [ self . func . __name__ ] = self . func ( obj ) <EOL> return value <EOL> class SimpleProxy ( object ) : <EOL> def __init__ ( self , factory ) : <EOL> self . factory = factory <EOL> self . object = empty <EOL> def __str__ ( self ) : <EOL> if self . object is empty : <EOL> self . object = self . factory ( ) <EOL> return str ( self . object ) <EOL> class CachedPropertyProxy ( object ) : <EOL> def __init__ ( self , factory ) : <EOL> self . factory = factory <EOL> @ cached_property <EOL> def object ( self ) : <EOL> return self . factory ( ) <EOL> def __str__ ( self ) : <EOL> return str ( self . object ) <EOL> class LocalsSimpleProxy ( object ) : <EOL> def __init__ ( self , factory ) : <EOL> self . factory = factory <EOL> self . object = empty <EOL> def __str__ ( self , func = str ) : <EOL> if self . object is empty : <EOL> self . object = self . factory ( ) <EOL> return func ( self . object ) <EOL> class LocalsCachedPropertyProxy ( object ) : <EOL> def __init__ ( self , factory ) : <EOL> self . factory = factory <EOL> @ cached_property <EOL> def object ( self ) : <EOL> return self . factory ( ) <EOL> def __str__ ( self , func = str ) : <EOL> return func ( self . object ) <EOL> @ pytest . fixture ( scope = "<STR_LIT>" , params = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> def impl ( request ) : <EOL> return globals ( ) [ request . param ] <EOL> def test_proto ( benchmark , impl ) : <EOL> obj = "<STR_LIT>" <EOL> proxied = impl ( lambda : obj ) <EOL> result = benchmark ( partial ( str , proxied ) ) <EOL> assert result == obj </s>
