mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
bpo-32677: Optimize str.isascii() (GH-5356)
This commit is contained in:
parent
ea8fc52e75
commit
bea57060c8
2 changed files with 43 additions and 4 deletions
|
@ -916,6 +916,13 @@ class BaseTest:
|
|||
self.checkequal(True, '\x00\x7f', 'isascii')
|
||||
self.checkequal(False, '\x80', 'isascii')
|
||||
self.checkequal(False, '\xe9', 'isascii')
|
||||
# bytes.isascii() and bytearray.isascii() has optimization which
|
||||
# check 4 or 8 bytes at once. So check some alignments.
|
||||
for p in range(8):
|
||||
self.checkequal(True, ' '*p + '\x7f', 'isascii')
|
||||
self.checkequal(False, ' '*p + '\x80', 'isascii')
|
||||
self.checkequal(True, ' '*p + '\x7f' + ' '*8, 'isascii')
|
||||
self.checkequal(False, ' '*p + '\x80' + ' '*8, 'isascii')
|
||||
|
||||
def test_isdigit(self):
|
||||
self.checkequal(False, '', 'isdigit')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue