Python 的 DeepCopy 的迭代版本
Python 2.5.2 是否有深度复制迭代版本的现有实现? 复制模块中提供的深度复制方法是递归的,并且在大型树上失败。 我无法在运行时安全地增加堆栈限制。
编辑
我确实追踪到了这一点:
http://code.activestate.com/recipes/302535/
我还没有测试过,但看起来它有潜力。
Is there an existing implementation of an iterative version of deepcopy for Python 2.5.2? The deepcopy method available from the copy module is recursive and fails on large trees. I am not in a position where we can safely increase the stack limit at runtime.
EDIT
I did track this down:
http://code.activestate.com/recipes/302535/
I haven't tested it, but it looks like it has potential.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定这是否有意义。
deepcopy
的全部意义不就是每个对象都会要求其子对象复制自己吗?想必您确切地知道要复制的对象类型以及它的子对象是什么样子,所以如果我是您,我只会编写自己的函数来复制它。 不应该太难。
I'm not sure this would make sense. Isn't the whole point of
deepcopy
that each object will ask its children to copy themselves?Presumably you know exactly what kind of object you're copying and what its children look like as well, so if I were you, I'd just write my own function to copy it. Shouldn't be too hard.
也许它可以与 Stackless Python 一起工作
Maybe it would work as such with Stackless Python