Skip to content

Commit 5425454

Browse files
authored
Merge pull request #5208 from jepler/small-memory-savings
Small memory savings
2 parents 1d74a6e + f1a3a86 commit 5425454

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

lib/utils/pyexec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ STATIC int pyexec_raw_repl_process_char(int c) {
370370
}
371371
goto reset;
372372
}
373-
mp_hal_stdout_tx_str("raw REPL; CTRL-B to exit\r\n");
373+
serial_write_compressed(translate("raw REPL; CTRL-B to exit\n"));
374374
goto reset;
375375
} else if (c == CHAR_CTRL_B) {
376376
// change to friendly REPL
@@ -469,7 +469,7 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
469469
return PYEXEC_FORCED_EXIT;
470470
} else if (ret == CHAR_CTRL_E) {
471471
// paste mode
472-
mp_hal_stdout_tx_str("\r\npaste mode; Ctrl-C to cancel, Ctrl-D to finish\r\n=== ");
472+
serial_write_compressed(translate("\npaste mode; Ctrl-C to cancel, Ctrl-D to finish\n=== "));
473473
vstr_reset(MP_STATE_VM(repl_line));
474474
repl.paste_mode = true;
475475
return 0;
@@ -545,7 +545,7 @@ int pyexec_raw_repl(void) {
545545
vstr_init(&line, 32);
546546

547547
raw_repl_reset:
548-
mp_hal_stdout_tx_str("raw REPL; CTRL-B to exit\r\n");
548+
serial_write_compressed(translate("raw REPL; CTRL-B to exit\n"));
549549

550550
for (;;) {
551551
vstr_reset(&line);

locale/circuitpython.pot

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ msgid ""
3535
"https://github.com/adafruit/circuitpython/issues\n"
3636
msgstr ""
3737

38+
#: lib/utils/pyexec.c
39+
msgid ""
40+
"\n"
41+
"paste mode; Ctrl-C to cancel, Ctrl-D to finish\n"
42+
"=== "
43+
msgstr ""
44+
3845
#: py/obj.c
3946
msgid " File \"%q\""
4047
msgstr ""
@@ -3973,6 +3980,10 @@ msgstr ""
39733980
msgid "queue overflow"
39743981
msgstr ""
39753982

3983+
#: lib/utils/pyexec.c
3984+
msgid "raw REPL; CTRL-B to exit\n"
3985+
msgstr ""
3986+
39763987
#: py/parse.c
39773988
msgid "raw f-strings are not implemented"
39783989
msgstr ""

main.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,7 @@ STATIC bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec
212212
return false;
213213
}
214214
mp_hal_stdout_tx_str(filename);
215-
const compressed_string_t* compressed = translate(" output:\n");
216-
char decompressed[decompress_length(compressed)];
217-
decompress(compressed, decompressed);
218-
mp_hal_stdout_tx_str(decompressed);
215+
serial_write_compressed(translate(" output:\n"));
219216
pyexec_file(filename, exec_result);
220217
#if CIRCUITPY_ATEXIT
221218
shared_module_atexit_execute(exec_result);

py/objgenerator.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,13 @@ STATIC void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_pri
185185
mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in);
186186
#if MICROPY_PY_ASYNC_AWAIT
187187
if (self->coroutine_generator) {
188-
mp_printf(print, "<coroutine object '%q' at %p>", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
189-
return;
188+
mp_printf(print, "<%q object '%q' at %p>", MP_QSTR_coroutine, mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
189+
} else {
190+
mp_printf(print, "<%q object '%q' at %p>", MP_QSTR_generator, mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
190191
}
191-
#endif
192+
#else
192193
mp_printf(print, "<generator object '%q' at %p>", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
194+
#endif
193195
}
194196

195197
mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val) {

py/objtraceback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const mp_obj_traceback_t mp_const_empty_traceback_obj = {{&mp_type_traceback}, 0
3232
STATIC void mp_obj_traceback_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
3333
(void)kind;
3434
mp_obj_traceback_t *o = MP_OBJ_TO_PTR(o_in);
35-
mp_printf(print, "<traceback object at 0x%p>", o);
35+
mp_printf(print, "<%q object at %p>", MP_QSTR_traceback, o);
3636
}
3737

3838
const mp_obj_type_t mp_type_traceback = {

0 commit comments

Comments
 (0)