On Thu, Apr 8, 2010 at 8:45 PM, Cliff Hill <xlorep@darkhelm.org> wrote:
Why not use Python's own pickle for it? I'm not entirely certain that Python classes could be serialized using Java's serialization, but pickling will work, and is the python equivalent (more or less).

Unless I'm completely mistaken, Pickle won't serialize arbitrary user defined classes (it serializes code by name rather than by value). So it might not be what the original poster wants. 

(People have bumped into this before, for example:

http://code.activestate.com/recipes/572213-pickle-the-interactive-interpreter-state/

But I have no experience with this approach and it's definitely hackish.)

best,  

Marc.


On Mon, Apr 5, 2010 at 2:29 AM, Tony Locke <tlocke@tlocke.org.uk> wrote:
Hi,

For performance reasons I tried to serialize a PyCode object, so I
could re-use it rather than compiling from the source each time.
However on attempting to serialize the PyCode object I get
java.io.NotSerializableException: org.python.core.CompilerFlags

Here's some code that will reproduce the problem:

PythonInterpreter interp = new PythonInterpreter();
PyCode code = interp.compile("jython_rocks = True");
ObjectOutputStream ow = new ObjectOutputStream(new
FileOutputStream(File.createTempFile("compscript", null)));
ow.writeObject(code);
ow.close();

Is this a genuine problem, or am I on the wrong track?

Cheers,

Tony.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users



--
"I'm not responcabel fer my computer's spleling errnors" - Xlorep DarkHelm
Website: http://darkhelm.org

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users