how to deepcopy a queue in python(如何在python中深度复制队列)
问题描述
如何在 python 中深度复制队列?谢谢
Hi How to deepcopy a Queue in python? Thanks
推荐答案
queue
The queue
module in Python is used for synchronizing shared data between threads. It is not intended as a data structure and it doesn't support copying (not even shallow copy).
(.get
和.put
可以对一个Queue进行多次deepcopy,但是原来的Queue会被销毁.)
(It is possible to construct many deepcopy's of a Queue by .get
and .put
, but the original Queue will be destroyed.)
如果您想将队列(或堆栈)作为数据结构,使用 collections.deque
.如果您想要优先级队列,请使用 heapq
模块.deque 支持 deepcopy.heapq 由列表支持,因此也支持 deepcopy.
If you want to have a queue (or stack) as a data structure, use a collections.deque
. If you want a priority queue, use the heapq
module. The deque supports deepcopy. heapq is backed by a list, so deepcopy is also supported.
这篇关于如何在python中深度复制队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在python中深度复制队列


- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01