summaryrefslogtreecommitdiffstatshomepage
path: root/py/makeqstrdata.py
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-10-21 11:06:32 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-10-21 11:06:32 +0300
commit9956fd0710c3866b9df37857c9aa62b8bb681403 (patch)
treed3b2a944aeb95396ee45403833c7bc4f46365cc6 /py/makeqstrdata.py
parentf2baa9ec245a66c4cd7d990e39a4af3f6fab1cb7 (diff)
downloadmicropython-9956fd0710c3866b9df37857c9aa62b8bb681403.tar.gz
micropython-9956fd0710c3866b9df37857c9aa62b8bb681403.zip
py/objtype: Fit qstrs for special methods in byte type.
Update makeqstrdata.py to sort strings starting with "__" to the beginning of qstr list, so they get low qstr id's, guaranteedly fitting in 8 bits. Then use this property to further compact op_id => qstr mapping arrays.
Diffstat (limited to 'py/makeqstrdata.py')
-rw-r--r--py/makeqstrdata.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py
index 7249769f47..38fde1a9c6 100644
--- a/py/makeqstrdata.py
+++ b/py/makeqstrdata.py
@@ -108,7 +108,15 @@ def parse_input_headers(infiles):
continue
# add the qstr to the list, with order number to retain original order in file
- qstrs[ident] = (len(qstrs), ident, qstr)
+ order = len(qstrs)
+ # but put special method names like __add__ at the top of list, so
+ # that their id's fit into a byte
+ if ident == "":
+ # Sort empty qstr above all still
+ order = -200000
+ elif ident.startswith("__"):
+ order -= 100000
+ qstrs[ident] = (order, ident, qstr)
if not qcfgs:
sys.stderr.write("ERROR: Empty preprocessor output - check for errors above\n")