mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
6a65eba44b
commit
d07d9f4c43
4 changed files with 48 additions and 19 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue