This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cheryl.sabella
Recipients cheryl.sabella, serhiy.storchaka, terry.reedy
Date 2018-02-24.18:56:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1519498605.58.0.467229070634.issue32880@psf.upfronthosting.co.za>
In-reply-to
Content
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.  :-)
History
Date User Action Args
2018-02-24 18:56:45cheryl.sabellasetrecipients: + cheryl.sabella, terry.reedy, serhiy.storchaka
2018-02-24 18:56:45cheryl.sabellasetmessageid: <1519498605.58.0.467229070634.issue32880@psf.upfronthosting.co.za>
2018-02-24 18:56:45cheryl.sabellalinkissue32880 messages
2018-02-24 18:56:45cheryl.sabellacreate