简体   繁体   English

python 是否在用于列表元素的“del”之后创建一个新列表?

[英]Does python create a new List after 'del' in used on an element of the List?

I plan to use an array as a stack for a binary tree print operation.我计划使用数组作为二叉树打印操作的堆栈。 Will it be more efficient to use Del operator to delete a node object from the list when it is printed, or sould I substitute some check symbol instead of the node object?在打印时使用 Del 运算符从列表中删除节点 object 会更有效,还是我应该用一些复选符号代替节点 object?

Is del operation efficient? del操作效率高吗? After del operation does python still store the list contagiously? del 操作后 python 是否仍然传染存储列表?

It is an efficieny question.这是一个效率问题。

Generally Python List is perfect candidate for using it as a stack.通常 Python List 是将其用作堆栈的完美候选者。

https://docs.python.org/3/tutorial/datastructures.html#using-lists-as-stacks https://docs.python.org/3/tutorial/datastructures.html#using-lists-as-stacks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM