Beautiful Soup will never run as fast as ElementTree or a
custom-built SGMLParser
subclass. ElementTree is written in C, and SGMLParser
lets you write your own mini-Beautiful Soup that only
does what you want. The point of Beautiful Soup is to save programmer
time, not processor time.
Beautiful Soup 不会像ElementTree或者自定义的SGMLParser
子类一样快。
ElementTree是用C写的,并且做那些你想要做的事。
Beautiful Soup是用来节省程序员的时间,而不是处理器的时间。
That said, you can speed up Beautiful Soup quite a lot by only
parsing the parts of the document you need, and you
can make unneeded objects get garbage-collected by using extract
.
但是你可以加快Beautiful Soup通过解析部分的文档,