summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBruce Merry <bmerry@gmail.com>2020-01-29 07:09:24 (GMT)
committerGitHub <noreply@github.com>2020-01-29 07:09:24 (GMT)
commitd07d9f4c43bc85a77021bcc7d77643f8ebb605cf (patch)
tree1a34ea430e52347e71547a55e4fd994634bd3358 /Lib
parent6a65eba44bfd82ccc8bed4b5c6dd6637549955d5 (diff)
downloadcpython-d07d9f4c43bc85a77021bcc7d77643f8ebb605cf.zip
cpython-d07d9f4c43bc85a77021bcc7d77643f8ebb605cf.tar.gz
cpython-d07d9f4c43bc85a77021bcc7d77643f8ebb605cf.tar.bz2
bpo-36051: Drop GIL during large bytes.join() (GH-17757)
Improve multi-threaded performance by dropping the GIL in the fast path of bytes.join. To avoid increasing overhead for small joins, it is only done if the output size exceeds a threshold.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_bytes.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index ddcf367..770e2c5 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -547,9 +547,13 @@ class BaseBytesTest:
self.assertEqual(dot_join([bytearray(b"ab"), b"cd"]), b"ab.:cd")
self.assertEqual(dot_join([b"ab", bytearray(b"cd")]), b"ab.:cd")
# Stress it with many items
- seq = [b"abc"] * 1000
- expected = b"abc" + b".:abc" * 999
+ seq = [b"abc"] * 100000
+ expected = b"abc" + b".:abc" * 99999
self.assertEqual(dot_join(seq), expected)
+ # Stress test with empty separator
+ seq = [b"abc"] * 100000
+ expected = b"abc" * 100000
+ self.assertEqual(self.type2test(b"").join(seq), expected)
self.assertRaises(TypeError, self.type2test(b" ").join, None)
# Error handling and cleanup when some item in the middle of the
# sequence has the wrong type.