Answer the question
In order to leave comments, you need to log in
Thread allocation in Python?
The code:
import time
t1 = time.time()
with open(r'Числа от одного до трилиарда.txt','r')as f:
for i in f:
print(i)
t2 = time.time()
print(t2-t1)
Answer the question
In order to leave comments, you need to log in
1. "The queue library does not help because big data" what? where did you get this from?
2. One thread reads the file and puts it in the queue, several threads are already reading from the queue.
3. But all this will not save you, print is not threadsafe, and it must be wrapped in Lock, which loses the meaning of the Wishlist.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question