Empty op name printed when missing from mp_binary_op_method_name
With MICROPY_PY_ALL_SPECIAL_METHODS =0,
>>> 1 + 1
2
>>> 1 + 1 / 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported types for : 'int', 'int'
>>>
You can see the print is a bit broken and it makes you question whether something deeper has gone wrong. I think it would be better to print something, like "unknown" or "unknown op".
For example, [0 ... MP_BINARY_OP_NUM_RUNTIME-1] = MP_QSTR_unknown, as the first line of mp_binary_op_method_name does the trick. It basically adds just this single "unknown" qstr.
makeqstrdata: Put special method names early.
In circuitpython, these QSTRs are close to falling out of the set of qstrs that fit in a byte, especially as we have added other qstrs that start with underscores causing xor to sort later. By putting them in this list, they're guaranteed to appear early and avoid problems.
I'm not entirely sure of the impact of this; does it force the strings to appear? for instance is __float__ added regardless of MICROPY_PY_BUILTINS_FLOAT? It appears so, which probably makes this approach unsuitable.
Perhaps an even greater savings would be possible if the sorting were such that mp_unary_op_method_name (and ditto binary) could be eliminated: Have MP_UNARY_OP_BASE = MP_QSTR__abs__ and ensure the invariant that e.g., MP_UNARY_OP_BASE + MP_UNARY_OP_NOT == MP_QSTR___not__. However, this probably saves <50 bytes, the tables are quite small.