Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

564 chardet performance binary content #565

Merged
merged 3 commits into from Sep 30, 2022

Conversation

mlissner
Copy link
Member

It turns out that r.text makes calls to chardet each time it is called. That's
not great because chardet can be slow and use a lot of memory, particularly
when checking PDFs.

Instead of doing that or checking if things are PDFs all the time, simply use
the binary content instead of the text.

Fixes: #564
Relates to: psf/requests#6250

It turns out that r.text makes calls to chardet each time it is called. That's
not great because chardet can be slow and use a lot of memory, particularly
when checking PDFs.

Instead of doing that or checking if things are PDFs all the time, simply use
the binary content instead of the text.

Fixes: #564
Relates to: psf/requests#6250
Copy link
Contributor

@albertisfu albertisfu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this works well and seems good to me.

When checking this I noticed a test that needed to be updated after I changed the NDA magic link URL to skip the attachment page, so I added the fix here, hope it's ok.

The weird thing is that tests action passed even though there was that broken test:
https://github.com/freelawproject/juriscraper/actions/runs/3154850047/jobs/5132902032#step:5:2230

@mlissner
Copy link
Member Author

The weird thing is that tests action passed even though there was that broken test:

Huh? Does it return an exit code of zero when you run the python setup.py test command on failing tests?

@mlissner mlissner merged commit 2edd72a into main Sep 30, 2022
@mlissner mlissner deleted the 564-chardet-performance-binary-content branch September 30, 2022 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Status: Done
Development

Successfully merging this pull request may close these issues.

r.text can make calls to chardet which are very slow
2 participants