[issue32880] IDLE: Fix and update and cleanup pyparse
Cheryl Sabella
report at bugs.python.org
Sat Feb 24 13:23:23 EST 2018
Cheryl Sabella <chekat2 at gmail.com> added the comment:
I also timed this for a `_tran` optimization (instead of looping and doing the `ord`), but it didn't really make a difference.
```
_tran = defaultdict(lambda: 'x')
_tran.update({40: 40, # ord('(')
91: 40, # ord('[')
123: 40, # ord('{')
41: 41, # ord(')')
93: 41, # ord(']')
125: 41, # ord('}')
34: 34, # ord('"')
39: 39, # ord("'")
92: 92, # ord("\\")
10: 10, # ord("\n")
35: 35, # ord("#")
})
```
I think both the loop and the above mapping are equally difficult to understand without stopping to think about it.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32880>
_______________________________________
More information about the Python-bugs-list
mailing list