|
52 | 52 | codepoint2name[ord("|")] = "pipe" |
53 | 53 | codepoint2name[ord("~")] = "tilde" |
54 | 54 |
|
55 | | -# static qstrs, should be sorted |
| 55 | +# static qstrs, unsorted. |
56 | 56 |
|
57 | 57 | static_qstr_list = [ |
58 | 58 | "", |
|
89 | 89 | "__repr__", |
90 | 90 | "__setitem__", |
91 | 91 | "__str__", |
| 92 | + "__bool__", |
| 93 | + "__pos__", |
| 94 | + "__neg__", |
| 95 | + "__invert__", |
| 96 | + "__abs__", |
| 97 | + "__float__", |
| 98 | + "__complex__", |
| 99 | + "__sizeof__", |
| 100 | + "__lt__", |
| 101 | + "__gt__", |
| 102 | + "__eq__", |
| 103 | + "__le__", |
| 104 | + "__ge__", |
| 105 | + "__ne__", |
| 106 | + "__contains__", |
| 107 | + "__iadd__", |
| 108 | + "__isub__", |
| 109 | + "__imul__", |
| 110 | + "__imatmul__", |
| 111 | + "__ifloordiv__", |
| 112 | + "__itruediv__", |
| 113 | + "__imod__", |
| 114 | + "__ipow__", |
| 115 | + "__ior__", |
| 116 | + "__ixor__", |
| 117 | + "__iand__", |
| 118 | + "__ilshift__", |
| 119 | + "__irshift__", |
| 120 | + "__add__", |
| 121 | + "__sub__", |
| 122 | + "__mul__", |
| 123 | + "__matmul__", |
| 124 | + "__floordiv__", |
| 125 | + "__truediv__", |
| 126 | + "__mod__", |
| 127 | + "__divmod__", |
| 128 | + "__pow__", |
| 129 | + "__or__", |
| 130 | + "__xor__", |
| 131 | + "__and__", |
| 132 | + "__lshift__", |
| 133 | + "__rshift__", |
| 134 | + "__radd__", |
| 135 | + "__rsub__", |
| 136 | + "__rmul__", |
| 137 | + "__rmatmul__", |
| 138 | + "__rfloordiv__", |
| 139 | + "__rtruediv__", |
| 140 | + "__rmod__", |
| 141 | + "__rpow__", |
| 142 | + "__ror__", |
| 143 | + "__rxor__", |
| 144 | + "__rand__", |
| 145 | + "__rlshift__", |
| 146 | + "__rrshift__", |
| 147 | + "__get__", |
| 148 | + "__set__", |
| 149 | + "__delete__", |
92 | 150 | "ArithmeticError", |
93 | 151 | "AssertionError", |
94 | 152 | "AttributeError", |
|
228 | 286 | ] |
229 | 287 |
|
230 | 288 | # this must match the equivalent function in qstr.c |
231 | | - |
232 | | - |
233 | 289 | def compute_hash(qstr, bytes_hash): |
234 | 290 | hash = 5381 |
235 | 291 | for b in qstr: |
@@ -305,16 +361,6 @@ def parse_input_headers(infiles): |
305 | 361 |
|
306 | 362 | # add the qstr to the list, with order number to retain original order in file |
307 | 363 | order = len(qstrs) |
308 | | - # but put special method names like __add__ at the top of list, so |
309 | | - # that their id's fit into a byte |
310 | | - if ident == "": |
311 | | - # Sort empty qstr above all still |
312 | | - order = -200000 |
313 | | - elif ident == "__dir__": |
314 | | - # Put __dir__ after empty qstr for builtin dir() to work |
315 | | - order = -190000 |
316 | | - elif ident.startswith("__"): |
317 | | - order -= 100000 |
318 | 364 | qstrs[ident] = Qstr(order, ident, qstr) |
319 | 365 |
|
320 | 366 | if not qcfgs: |
@@ -374,11 +420,11 @@ def print_qstr_data(qstrs): |
374 | 420 | q1_values = [q for q in qstrs.values() if q.order >= 0] |
375 | 421 |
|
376 | 422 | # go through each qstr in pool 0 and print it out. pool0 has special sort. |
377 | | - for q in sorted(q0_values, key=lambda x: x.order): |
| 423 | + for q in sorted(q0_values, key=lambda x: x.qhash): |
378 | 424 | print('QDEF0(MP_QSTR_%s, %d, %d, "%s")' % (q.ident, q.qhash, q.qlen, q.qdata)) |
379 | 425 |
|
380 | 426 | # go through each qstr in pool 1 and print it out. pool1 is regularly sorted. |
381 | | - for q in sorted(q1_values, key=lambda x: (x.qhash, x.qlen)): |
| 427 | + for q in sorted(q1_values, key=lambda x: x.qhash): |
382 | 428 | print('QDEF1(MP_QSTR_%s, %d, %d, "%s")' % (q.ident, q.qhash, q.qlen, q.qdata)) |
383 | 429 |
|
384 | 430 |
|
|
0 commit comments