Skip to content

Commit 14f2c58

Browse files
committed
Improve speed on Python 3
This speeds it up quite a bit, but it's still running noticeably slower and I haven't figured out why yet.
1 parent 6ad9678 commit 14f2c58

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

textile/functions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import re
2222
import uuid
23-
from sys import maxunicode
23+
from sys import maxunicode, version_info
2424

2525

2626
try:
@@ -232,8 +232,10 @@ def textile(self, text, rel=None, head_offset=0, html_type='xhtml',
232232
# characters.
233233
# we need to know if there are unicode charcters in the text.
234234
# return True as soon as a unicode character is found, else, False
235+
# Python 3 is better equipped to handle unicode data, so this hackery
236+
# is version-specific.
235237
self.text_has_unicode = next((True for c in text if ord(c) > 128),
236-
False)
238+
False) and version_info < (3,)
237239

238240
if self.text_has_unicode:
239241
uppers = []

0 commit comments

Comments
 (0)