Skip to content

Commit

Permalink
py: Remove 5 TODOs in emitbc, objrange and repl.
Browse files Browse the repository at this point in the history
These TODOs don't need to be done:

- Calling functions with keyword arguments is less common than without
  them, so adding an extra byte overhead to all calls regardless of whether
  they use keywords or not would overall increase generated bytecode size.

- Restricting `range` objects to machine-sized ints has been adequate for
  a long time now, so no need to change that and make it more complicated
  and slower.

- Printing spaces in tab completion does not need to be optimised.

Signed-off-by: Damien George <[email protected]>
  • Loading branch information
dpgeorge committed Jul 18, 2024
1 parent fce3cea commit e00d80d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
4 changes: 2 additions & 2 deletions py/emitbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,10 @@ static void emit_bc_call_function_method_helper(emit_t *emit, int stack_adj, mp_
// each positional arg is one object, each kwarg is two objects, the key
// and the value and one extra object for the star args bitmap.
stack_adj -= (int)n_positional + 2 * (int)n_keyword + 1;
emit_write_bytecode_byte_uint(emit, stack_adj, bytecode_base + 1, (n_keyword << 8) | n_positional); // TODO make it 2 separate uints?
emit_write_bytecode_byte_uint(emit, stack_adj, bytecode_base + 1, (n_keyword << 8) | n_positional);
} else {
stack_adj -= (int)n_positional + 2 * (int)n_keyword;
emit_write_bytecode_byte_uint(emit, stack_adj, bytecode_base, (n_keyword << 8) | n_positional); // TODO make it 2 separate uints?
emit_write_bytecode_byte_uint(emit, stack_adj, bytecode_base, (n_keyword << 8) | n_positional);
}
}

Expand Down
2 changes: 0 additions & 2 deletions py/objrange.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

typedef struct _mp_obj_range_it_t {
mp_obj_base_t base;
// TODO make these values generic objects or something
mp_int_t cur;
mp_int_t stop;
mp_int_t step;
Expand Down Expand Up @@ -72,7 +71,6 @@ static mp_obj_t mp_obj_new_range_iterator(mp_int_t cur, mp_int_t stop, mp_int_t

typedef struct _mp_obj_range_t {
mp_obj_base_t base;
// TODO make these values generic objects or something
mp_int_t start;
mp_int_t stop;
mp_int_t step;
Expand Down
1 change: 0 additions & 1 deletion py/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ static void print_completions(const mp_print_t *print,
gap += WORD_SLOT_LEN;
}
if (line_len + gap + d_len <= MAX_LINE_LEN) {
// TODO optimise printing of gap?
for (int j = 0; j < gap; ++j) {
mp_print_str(print, " ");
}
Expand Down

0 comments on commit e00d80d

Please sign in to comment.