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 anish.shah
Recipients Kunal Grover, anish.shah, demian.brecht, jaraco, martin.panter, serhiy.storchaka
Date 2016-02-07.10:36:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1454841365.58.0.0687742856729.issue26302@psf.upfronthosting.co.za>
In-reply-to
Content
I ran regex and issuperset version on a random string. The regex one gives better performance. So, I have included the re.escape in the patch. 

>>> random_str = ''.join(random.choice(_LegalChars) for _ in range(10 ** 8))
>>> is_legal_key = re.compile('[%s]+' % re.escape(_LegalChars)).fullmatch
>>> Timer("is_legal_key(random_str)", setup="from __main__ import random_str, is_legal_key").timeit(1)
0.3168252399998437
>>> def is_legal_key(key):
...     return key and set(_LegalChars).issuperset(key)
... 
>>> Timer("is_legal_key(random_str)", setup="from __main__ import random_str, is_legal_key").timeit(1)
4.3335622880001665


Also, I have updated the patch. Can you please review it? :)
History
Date User Action Args
2016-02-07 10:36:05anish.shahsetrecipients: + anish.shah, jaraco, martin.panter, serhiy.storchaka, demian.brecht, Kunal Grover
2016-02-07 10:36:05anish.shahsetmessageid: <1454841365.58.0.0687742856729.issue26302@psf.upfronthosting.co.za>
2016-02-07 10:36:05anish.shahlinkissue26302 messages
2016-02-07 10:36:05anish.shahcreate