summaryrefslogtreecommitdiffstats
path: root/Lib/string.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/string.py')
-rw-r--r--Lib/string.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/string.py b/Lib/string.py
index 6386a95..cc60678 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -163,3 +163,15 @@ def expandtabs(s, tabsize):
res = res + line
line = ''
return res + line
+
+
+# Try importing optional built-in module "strop" -- if it exists,
+# it redefines some string operations that are 100-1000 times faster.
+# The manipulation with index_error is needed for compatibility.
+
+try:
+ from strop import *
+ from strop import index
+ index_error = ValueError
+except ImportError:
+ pass # Use the original, slow versions