You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know that I can pickle a dictionary or list of functions, then unpickle them and use the inspect.getsource to print the source of each of them, but that does not include the source of any globals that are referenced inside those functions. I'd like to be able to regenerate the source of all pickled objects to create runnable source. I have to think the globals are stored somewhere that can be inspected, but I wasn't able to find them.
The text was updated successfully, but these errors were encountered:
I was hoping to find a way to take code like this:
import foo
def unused_func(z):
return z ** z
def util_func(x):
return x * 2
def pickled_func(y):
return util_func(foo.square(y))
Then be able to pickle the pickled_func function, but also be able to reconstruct the source. In this case, that would generate the source for util_func and pickled_func, but leave out unused_func.
To be honest, this was mostly an attempt to get around the limitation that the Python version must be the exact version used when creating the pickled objects. If the source could be regenerated, it would at least work in the same minor Python version and possibly even more than that.
Nobody has worked on such a thing and it's quite different from the way cloudpickle has been built.
It might or might not be possible to achieve using Python inspection utils, but even if it is, would probably require a lot of work to implement and properly test and I have no plans to work on such a thing personally.
I know that I can pickle a dictionary or list of functions, then unpickle them and use the
inspect.getsource
to print the source of each of them, but that does not include the source of any globals that are referenced inside those functions. I'd like to be able to regenerate the source of all pickled objects to create runnable source. I have to think the globals are stored somewhere that can be inspected, but I wasn't able to find them.The text was updated successfully, but these errors were encountered: