@@ -629,14 +629,20 @@ def test_join(self):
629629 self .assertEqual (dot_join ([b"ab" , memoryview (b"cd" )]), b"ab.:cd" )
630630 self .assertEqual (dot_join ([bytearray (b"ab" ), b"cd" ]), b"ab.:cd" )
631631 self .assertEqual (dot_join ([b"ab" , bytearray (b"cd" )]), b"ab.:cd" )
632- # Stress it with many items
633- seq = [b"abc" ] * 100000
634- expected = b"abc" + b".:abc" * 99999
632+ # Stress it with many items or many views on immutable bytes
633+ N = 0x100000 # threshold for releasing the GIL in join()
634+ seq = [b"abc" ] * N
635+ expected = b"abc" + b".:abc" * (N - 1 )
636+ self .assertGreater (len (expected ), N )
635637 self .assertEqual (dot_join (seq ), expected )
638+ views = list (map (memoryview , seq ))
639+ self .assertEqual (dot_join (views ), expected )
636640 # Stress test with empty separator
637- seq = [ b"abc" ] * 100000
638- expected = b"abc" * 100000
641+ expected = b"abc" * N
642+ self . assertGreater ( len ( expected ), N )
639643 self .assertEqual (self .type2test (b"" ).join (seq ), expected )
644+ views = list (map (memoryview , seq ))
645+ self .assertEqual (self .type2test (b"" ).join (views ), expected )
640646 self .assertRaises (TypeError , self .type2test (b" " ).join , None )
641647 # Error handling and cleanup when some item in the middle of the
642648 # sequence has the wrong type.
0 commit comments