Skip to content

Commit db110a0

Browse files
committed
Optimize marshalled data handling by using bytearray instead of bytes
1 parent 971a52b commit db110a0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Programs/_freeze_module.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ def read_text(inpath: str) -> bytes:
2020
return f.read()
2121

2222

23-
def compile_and_marshal(name: str, text: bytes) -> bytes:
23+
def compile_and_marshal(name: str, text: bytes) -> bytearray:
2424
filename = f"<frozen {name}>"
2525
# exec == Py_file_input
2626
code = compile(text, filename, "exec", optimize=0, dont_inherit=True)
27-
return marshal.dumps(code)
27+
return bytearray.dumps(code)
2828

2929

3030
def get_varname(name: str, prefix: str) -> str:
3131
return f"{prefix}{name.replace('.', '_')}"
3232

3333

34-
def write_code(outfile, marshalled: bytes, varname: str) -> None:
34+
def write_code(outfile, marshalled: bytearray, varname: str) -> None:
3535
data_size = len(marshalled)
3636

3737
outfile.write(f"const unsigned char {varname}[] = {{\n")

0 commit comments

Comments
 (0)