我是pypy的新手,想看看它能否加快我的应用速度。Pypy文档表示,Pypy支持标准python库,只有少数例外。我在使用ElementTree进行xml解析的简单测试用例中遇到的问题表现不同,因为pypy只保留每个标记的第一个字母。
ElementTree documentation
):
<?xml version="1.0"?>
<data>
<country name="Liechtenstein">
<rank>1</rank>
<year>2008</year>
<gdppc>141100</gdppc>
<neighbor name="Austria" direction="E"/>
<neighbor name="Switzerland" direction="W"/>
</country>
</data>
我的python代码:
import xml.etree.ElementTree as ET
tree = ET.parse('ettest.xml')
root = tree.getroot()
print root.tag
$ python ettest.py
data
$ pypy ettest.py
d
Pypy只打印标签的第一个字母。我认为ElementTree是纯python,所以我想知道它是pypy bug还是我错过了一些pypy魔术?
$ python -V
Python 2.7.13 :: Continuum Analytics, Inc.
$ pypy --version
Python 2.7.13 (c925e7381036, Jun 06 2017, 05:28:16)
[PyPy 5.8.0 with MSC v.1500 32 bit]