[pypy-dev] Help with "Exception: unexpected prebuilt constant"
anto.cuni at gmail.com
Fri Oct 9 18:30:27 CEST 2009
Philip Guo wrote:
> Thanks for the informative reply, Antonio! My (probably dumb) follow-up
> question is: Is pickle (or cPickle) supported by RPython? The bottom
> line is that I need to serialize some data structures from my modified
> PyPy interpreter to disk so that data can persist across successive
> interpreter runs. Pickling is the most obvious way to do so, but it
> requires a Python built-in file object.
pickle and cpickle are not supported by RPython.
If you need to serialize interp-level objects, I fear the only way is to
manually write the code to write them to disk and read back. You might want to
have a look at rlib.rmarshal, which can be used to serialize simple objects
such as numbers, lists and tuples.
On the other hand, remember that you have the whole PyPy python interpreter in
your hands: depending on what you are trying to do, you could use it to
interact with the fully working cPickle modules. But please notice that this
solution works only if you want to serialize app-level objects (i.e. all the
objects that are called as w_* inside the pypy sources).
> If pickling doesn't work, what other way of persisting data on disk do
> you suggest? (e.g., printing it to a file as plaintext and then
> eval-ing it again? does eval() even work in RPython?)
no, eval() doesn't work in RPython.
More information about the Pypy-dev