Skip to content

Commit e689695

Browse files
Merge pull request #54 from Zektopic/bolt/optimize-string-join-11477192544837518008
⚡ Bolt: Replace deprecated string.join with native str.join in jungo-image.py
2 parents 2353790 + 665931f commit e689695

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

.jules/bolt.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@
4747
## 2025-01-20 - [Python CRC32 Chunked File I/O in sercomm-kernel-header]
4848
**Learning:** In `scripts/sercomm-kernel-header.py`, reading entire kernel and rootfs files into memory with `.read()` and `.read(rootfs_size)` causes excessive memory bloat (O(N) complexity). Memory limit issues can easily happen on large firmware images.
4949
**Action:** Use an incremental CRC approach over chunked reads for large files (`crc = binascii.crc32(chunk, crc)`). This maintains O(1) memory usage, improving efficiency and memory footprint.
50+
## 2026-04-11 - [string.join deprecation and performance issue]
51+
**Learning:** In Python 3, string.join() was removed. The native ''.join(iterable) is the correct alternative, and also yields a performance improvement.
52+
**Action:** Replace string.join with ''.join in the codebase where encountered.

scripts/flashing/jungo-image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import getopt
3030
import getpass
3131
import telnetlib
32-
import string
3332
import binascii
3433
import socket
3534
import _thread
@@ -140,7 +139,8 @@ def image_dump(tn, dumpfile):
140139
print("Format error: %x != %x"%(a,count))
141140
sys.exit(2)
142141
count += 16
143-
f.write(binascii.a2b_hex(string.join(s[1:],'')))
142+
# Optimization: Use native ''.join instead of deprecated string.join for better performance and Python 3 compatibility
143+
f.write(binascii.a2b_hex("".join(s[1:])))
144144
tn.read_until(">",1)
145145

146146
f.close()

0 commit comments

Comments
 (0)