All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Lib.marshal.py Maven / Gradle / Ivy

Go to download

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

The newest version!
"""Marshal module written in Python.

This doesn't marshal code objects, but supports everything else.
Performance or careful error checking is not an issue.

"""

import cStringIO
from _marshal import Marshaller, Unmarshaller

def dump(x, f, version=2):
    Marshaller(f, version).dump(x)

# XXX - added just for debugging. remove!
def load(f, debug=False):
    u = Unmarshaller(f)
    if debug:
        u._debug()
    return u.load()

def dumps(x, version=2):
    f = cStringIO.StringIO()
    dump(x, f, version)
    return f.getvalue()

def loads(s):
    f = cStringIO.StringIO(s)
    return load(f)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy