Skip to content

Conversation

@Vizonex
Copy link

@Vizonex Vizonex commented Aug 12, 2025

It's hard to name all the changes I've made to this library but I think aiohttp may have used this library at some point or is currently using it. I am a contributor over there and I had the impression that I should try and help out with this library at some point in the future to keep the code up to date. But here's a rundown of what I've added and changed.

  • Removed the Frontend Class in Favor of Cython's for performance and incase typehinting was a concern (which it always has been especially for me), I have included a stubfile for it so that python's typeshead doesn't need to support it and marked it with a py.typed file
  • Working to fix windows builds since I develop from a Windows 10 Laptop most of the time. There seems to be a bit of a macro issue in uchardet but I should be able to provide a patch for uchardet here in a bit.
  • Replaced bytes objects that are internal and never accessed by python with bytearray for better control over clearing results.
  • Better Exceptions for why cchardet may have failed which most of them are memory related so MemoryError was the best choice for that.
  • added __dealloc__ as an aggressive measure to ensure objects are being freed correctly so that there is never a chance of a memory leak.
  • added a build_ext command class for this library that I have been using in most of my other resources and libraries that I own or maintain and you have my permission to use it as you wish. it has extra commands for helping other users with annotating over the cython code as well as compiling
  • I setup a better flag for windows users who may want to compile this library themselves without needing to go and get a special compiler.
  • I replaced some sections of code that could run a bit smoother using CPython functions so that cython doesn't need to generate these specific portions of code hopefully giving a performance boost.

…in favor of Cython backend & typehint everything
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant