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中深度复制队列


基础教程推荐
- 求两个直方图的卷积 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 包装空间模型 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01