We weren't able to pickle the function we obtained from compile and exec. This PR gets around this by running compile and exec again upon deserializing. This was the easiest option to implement.
Another option (instead of calling compile and exec) would be to serialize the components that make up the code object, then create the code object and function using types.CodeType and types.FunctionType. Similarly, we don't need to recreate the ScopedFunction from innerscope either, but doing so is the easiest.
In other words, I have put very little effort in optimizing for performance.
We weren't able to pickle the function we obtained from
compile
andexec
. This PR gets around this by runningcompile
andexec
again upon deserializing. This was the easiest option to implement.Another option (instead of calling
compile
andexec
) would be to serialize the components that make up the code object, then create the code object and function usingtypes.CodeType
andtypes.FunctionType
. Similarly, we don't need to recreate theScopedFunction
frominnerscope
either, but doing so is the easiest.In other words, I have put very little effort in optimizing for performance.