import sys from org.python.core import PyStringMap from org.python.util import PythonObjectInputStream from java.io import ObjectOutputStream, ByteArrayOutputStream, ByteArrayInputStream for i in xrange(10000): d = PyStringMap() for j in xrange(i): d.__setitem__(str(j), j) print "trying size " + str(i) outbuffer = ByteArrayOutputStream() out = ObjectOutputStream(outbuffer) out.writeObject(d) out.close() inbuffer = ByteArrayInputStream(outbuffer.toByteArray()) instream = PythonObjectInputStream(inbuffer) d2 = instream.readObject() instream.close() print len(d2) print d2.get("foo")