2% performance improvement on tree construction

Bug #1899358 reported by Morotti on 2020-10-11
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Beautiful Soup

Bug Description

(patch in the next comment)

optimize function bs4/__init__.py endData()

endData() is called 3 times per tag to process the HTML document. It does nothing two third of the calls because there is nothing more to process.

122622 calls on my perf test. 45572 calls that actually do something (going into the if section).

It is calling self.string_container() as the first line, even when there is nothing to do, waste of resources. Move the call to the end of the function so it's only called when needed.

It makes document construction 1% to 2.5% faster.

Morotti (rmorotti) wrote :

patch attached

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments