Author: Ned Batchelder <n...@nedbatchelder.com> Branch: nedbat-sandbox Changeset: r50003:0cca0b181f5c Date: 2011-11-29 22:00 -0500 http://bitbucket.org/pypy/pypy/changeset/0cca0b181f5c/
Log: Avoid a compile at startup by using our own marshalling of stat results, instead of calling into rmarshal to do it. diff --git a/pypy/translator/sandbox/sandlib.py b/pypy/translator/sandbox/sandlib.py --- a/pypy/translator/sandbox/sandlib.py +++ b/pypy/translator/sandbox/sandlib.py @@ -50,6 +50,25 @@ marshal.dump(msg, g) else: marshal.dump(msg, g, 0) + elif resulttype is s_StatResult: + # Hand-coded marshal for stat results that mimics what rmarshal expects. + # marshal.dump(tuple(msg)) would have been too easy. rmarshal insists + # on 64-bit ints at places, even when the value fits in 32 bits. + import struct + st = tuple(msg) + fmt = "iIIiiiIfff" + buf = [] + buf.append(struct.pack("<ci", '(', len(st))) + for c, v in zip(fmt, st): + if c == 'i': + buf.append(struct.pack("<ci", c, v)) + elif c == 'I': + buf.append(struct.pack("<cq", c, v)) + elif c == 'f': + fstr = "%g" % v + buf.append(struct.pack("<cB", c, len(fstr))) + buf.append(fstr) + g.write(''.join(buf)) else: # use the exact result type for encoding from pypy.rlib.rmarshal import get_marshaller _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit