Why is elementtree.ElementTree.iterparse using so much memory?

落花浮王杯 提交于 2019-12-01 13:39:25

(The code as posted, with the second line indented, should not run.) http://bugs.python.org/issue14762 was a similar issue and the answer there is that you should clear each element (line A). Without seeing what outf is (or the code that created it), it is hard to answer the second question. If it were a StringIO object, the answer would be obvious. You might take a look at the tutorial linked in the second message of the tracker issue:

http://eli.thegreenplace.net/2012/03/15/processing-xml-in-python-with-elementtree/

Use xml.etree.cElementTree.iterparse() instead [in Python 2.x].

Life's too short to debug other people's bugs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!