Gumbo
An HTML5 parsing library in pure C99
... into a parse tree, and free that parse tree all at once. To install the python bindings, make sure that the C library is installed first, and then sudo python setup.py install from the root of the distro. This installs a 'gumbo' module; pydoc gumbo should tell you about it. Tested on over 2.5 billion pages from Google's index. Passes all html5lib tests, including the template tag.