4 ms·
Unfortunately, python doesn't let you serialize a function through pickle or other non-marshal serializations. The only cross-python solution is to actually hav
by michaelfairley 15y ago
Unfortunately, python doesn't let you serialize a function through pickle or other non-marshal serializations. The only cross-python solution is to actually have python read the source code and send it (rather than the bytecode) over the wire, which seems much more brittle to me.
See http://stackoverflow.com/questions/1253528/is-there-an-easy-way-to-pickle-a-python-function-or-otherwise-serialize-its-code http://stackoverflow.com/questions/1253528/is-there-an-easy-...
- munin 15y agooh yeah, if you run this script with different python versions, you will experience mysterious failures probably. in some limited testing I did, I was able to serialize a function on 64-bit Linux and have it execute on 32-bit Windows. I even went crazy and wrote using ctypes against the Win32 API on Linux and sent a string to be loads()ed by code on Windows... and that worked. (this isn't really python being awesome as much as bytecode languages working as designed... but as far as I know this is all working by happy co-incidence, unlike say Java, where the bytecode is designed to be cross-platform...)