Cheryl Sabella <[email protected]> added the comment:
I wish I could delete my last message (and duplicate posting of the one before.
On the last one, I didn't move my timings. I feel like an idiot. Anyway,
there is a difference.
```
start = time.time()
for i in range(1000000):
_tran = defaultdict(lambda: 'x')
_tran.update((ord(c), ord('(')) for c in "({[")
_tran.update((ord(c), ord(')')) for c in ")}]")
_tran.update((ord(c), ord(c)) for c in "\"'\\\n#")
end = time.time()
print(f'translate time: {end - start}')
```
translate time: 7.443669319152832
```
start = time.time()
for i in range(1000000):
_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("#")
})
end = time.time()
print(f'translate time: {end - start}')
```
translate time: 1.7251780033111572
It's still probably negligible since it's only done once and not a million
times. :-)
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32880>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com