Message312741
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. :-) |
|
Date |
User |
Action |
Args |
2018-02-24 18:56:45 | cheryl.sabella | set | recipients:
+ cheryl.sabella, terry.reedy, serhiy.storchaka |
2018-02-24 18:56:45 | cheryl.sabella | set | messageid: <1519498605.58.0.467229070634.issue32880@psf.upfronthosting.co.za> |
2018-02-24 18:56:45 | cheryl.sabella | link | issue32880 messages |
2018-02-24 18:56:45 | cheryl.sabella | create | |
|