Phuks-co / throat

Open Source link aggregator and discussion platform powering Phuks
https://phuks.co
MIT License
73 stars 32 forks source link

Speed up tests by not making BeautifulSoup guess the encoding #387

Closed happy-river closed 3 years ago

happy-river commented 3 years ago

If you pass a byte string to BeautifulSoup, without also giving it an encoding, it has to guess the encoding before parsing, which is computationally intensive. BeautifulSoup is used frequently in our tests. Passing an encoding to BeautifulSoup in the tests, where it is used on byte strings, made them complete 1.9% faster, in the average of several runs on my laptop.