2% performance improvement on tree construction

Bug #1899358 reported by Morotti
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Beautiful Soup
Fix Released
Undecided
Unassigned

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.

Revision history for this message
Morotti (rmorotti) wrote :

patch attached

Revision history for this message
Leonard Richardson (leonardr) wrote :

 Thanks for the patch. I've made this change in revision 597.

Changed in beautifulsoup:
status: New → Fix Committed
Revision history for this message
Leonard Richardson (leonardr) wrote :

Released in 4.10.0.

Changed in beautifulsoup:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.