diff options
author | INADA Naoki <methane@users.noreply.github.com> | 2018-01-28 09:59:12 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-28 09:59:12 +0900 |
commit | bea57060c863d0c3474c79350bd9c557f2ff0e7c (patch) | |
tree | aacefc63e6f0fecbc24fb7767ce21ecc293c8b16 /Lib/test/string_tests.py | |
parent | ea8fc52e75363276db23c6a8d7a689f79efce4f9 (diff) | |
download | cpython-git-bea57060c863d0c3474c79350bd9c557f2ff0e7c.tar.gz |
bpo-32677: Optimize str.isascii() (GH-5356)
Diffstat (limited to 'Lib/test/string_tests.py')
-rw-r--r-- | Lib/test/string_tests.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py index 4be1d21189..561b09a2d5 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -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') |