خرید بک لینک

Vote count: 0

In python there's a built-in heapq algorithm that gives you push, pop, nlargest, nsmallest... etc that you can apply to lists. However, there's also the queue.PriorityQueue class that seems to support more or less the same functionality. What's the difference, and when would you use one over the other?

asked 2 mins ago

1 Answer

Vote count: 0

Queue.PriorityQueue is a thread-safe class, while collections.heapq makes no thread-safety guarantees.

From the Queue module documentation:

The Queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The Queue class in this module implements all the required locking semantics. It depends on the availability of thread support in Python; see the threading module.

answered 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 14 ارديبهشت 1395 ساعت: 4:21

صفحه بندی