Skip to content

Commit 8260c7a

Browse files
committed
Merge branch 'test_bytes_from_list' into fast-bytes-creation-from-list-tuple-2
2 parents 8bbc021 + f3a9423 commit 8260c7a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import unittest
2+
import sys
3+
from threading import Thread, Barrier
4+
from test.support import threading_helper
5+
6+
threading_helper.requires_working_threading(module=True)
7+
8+
class BytesThreading(unittest.TestCase):
9+
10+
@threading_helper.reap_threads
11+
def test_conversion_from_list(self):
12+
number_of_threads = 10
13+
number_of_iterations = 10
14+
barrier = Barrier(number_of_threads)
15+
16+
x = [1, 2, 3, 4, 5]
17+
e = [ (ii,)*(2+4*ii) for ii in range(number_of_threads)] # range of sizes to extend
18+
def work(ii):
19+
barrier.wait()
20+
for _ in range(1000):
21+
bytes(x)
22+
x.extend(e[ii])
23+
if len(x) > 10:
24+
x[:] = [0]
25+
26+
for it in range(number_of_iterations):
27+
worker_threads = []
28+
for ii in range(number_of_threads):
29+
worker_threads.append(
30+
Thread(target=work, args=[ii]))
31+
with threading_helper.start_threads(worker_threads):
32+
pass
33+
34+
barrier.reset()
35+
36+
if __name__ == "__main__":
37+
unittest.main()

0 commit comments

Comments
 (0)