I understand that freezing strings in the flash saves RAM in micropython.
A source file containing
Code: Select all
MY_STRING = 'this is a long string, but I want it to be only a machine word in the RAM of the actual devcie'
Is is also possible to freeze a dictonary into the flash and import it, to reduce the RAM usage? Something like this:
Code: Select all
MY_DICTONARY = {1: 'hello', 2: 'world', 3: 'this is a long string, but I want it to be only a machine word in the RAM of the actual devcie'}
Or do I have to define each string in the dictonary as a constant and build the dictonary like this:
Code: Select all
MY_STRING_1 = 'hello'
MY_STRING_2= 'wolrd'
MY_STRING_3 = 'this is a long string, but I want it to be only a machine word in the RAM of the actual devcie'
Code: Select all
import my_strings_in_flash
my_dict = {1: my_strings_in_flash.MY_STRING_1, 2 : my_strings_in_flash.MY_STRING_2, 3: my_strings_in_flash.MY_STRING_3}