From c8c0fd4ca39fbdcf9ca5f2fc99ca4d6b81a28b65 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 25 Sep 2019 15:45:47 +1000 Subject: py: Rework and compress second part of bytecode prelude. This patch compresses the second part of the bytecode prelude which contains the source file name, function name, source-line-number mapping and cell closure information. This part of the prelude now begins with a single varible length unsigned integer which encodes 2 numbers, being the byte-size of the following 2 sections in the header: the "source info section" and the "closure section". After decoding this variable unsigned integer it's possible to skip over one or both of these sections very easily. This scheme saves about 2 bytes for most functions compared to the original format: one in the case that there are no closure cells, and one because padding was eliminated. --- tests/import/mpy_native.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/import') diff --git a/tests/import/mpy_native.py b/tests/import/mpy_native.py index 03abab349..749320dbb 100644 --- a/tests/import/mpy_native.py +++ b/tests/import/mpy_native.py @@ -56,8 +56,8 @@ user_files = { '/mod1.mpy': ( b'M\x05\x0b\x1f\x20' # header - b'\x24' # n bytes, bytecode - b'\x00\x05\x00\x00\x00\x00\xff' # prelude + b'\x20' # n bytes, bytecode + b'\x00\x08\x00\x00\x00\x00' # prelude b'\x51' # LOAD_CONST_NONE b'\x63' # RETURN_VALUE -- cgit v1.2.3