Example #1
0
 def freezef(self, obj):
     return freezef(obj)
Example #2
0
                        or     isinstance(obj, range) 
                        and    'range://'+str(obj)[5:]
                        or     (hasattr(__builtins__, 'bytearray')
                        and     isinstance(obj, bytearray))
                        and    'bytearray://'+str([i for i in obj])
                        or     (hasattr(__builtins__, 'memoryview')
                        and     isinstance(obj, memoryview))
                        and    'memoryview://'+str([i for i in obj])
                        or     isinstance(obj, complex) 
                        and    'complex://'+str(obj)
                        or     isinstance(obj, type) 
                        and    'type://'+str([obj.__name__,str(obj.__bases__),
                               flatten({f:obj.__dict__[f] for f in obj.__dict__
                        if     callable(obj.__dict__[f])})])
                        or     isinstance(obj, type(lambda: None)) 
                        and    'function://'+str(freezef(obj)) 
                        or     isinstance(obj, list) 
                        and    [flatten(i) for i in obj] 
                        or     isinstance(obj, dict) 
                        and    {(lambda x: isinstance(x, ntypes) 
                        and    str(type(x))[8:-2]+'://'+str(x) 
                        or     flatten(x))(i):flatten(obj[i]) for i in obj} 
                        or     obj)

restore = lambda obj, globs:\
                               (isinstance(obj, str) 
                        and    (lambda x: x.startswith('bytes://') 
                        and    bytes(x[8:], encoding = 'utf8') 
                        or     x.startswith('int://') 
                        and    int(x[6:]) 
                        or     x.startswith('float://')