mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 12:10:13 +01:00
26 lines
425 B
Python
26 lines
425 B
Python
# String operations which don't require allocation
|
|
|
|
try:
|
|
import micropython
|
|
|
|
micropython.heap_lock
|
|
except (ImportError, AttributeError):
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
micropython.heap_lock()
|
|
|
|
# Concatenating empty string returns original string
|
|
b"" + b""
|
|
b"" + b"1"
|
|
b"2" + b""
|
|
|
|
"" + ""
|
|
"" + "1"
|
|
"2" + ""
|
|
|
|
# If no replacements done, returns original string
|
|
"foo".replace(",", "_")
|
|
|
|
micropython.heap_unlock()
|