john-kurkowski / tldextract

Accurately separates a URL’s subdomain, domain, and public suffix, using the Public Suffix List (PSL).
BSD 3-Clause "New" or "Revised" License
1.83k stars 210 forks source link

Migrate ExtractResult from namedtuple to dataclass #306

Closed john-kurkowski closed 11 months ago

john-kurkowski commented 1 year ago

Changes the type of this library's core type ExtractResult from namedtuple to dataclass.

The bugfix in #300 was not the breaking change I wanted. It resulted in #305. This PR is to:

  1. Keep the #300 bugfix.
  2. Add flexibility to the library. For example, to add more metadata fields going forward. So not every addition of a field is a breaking change.
  3. Really warrant a major version bump, once. I'm considering yanking version 3.6.0 and making this PR's change the ~4.0.0~ major version bump.

Open Issues

john-kurkowski commented 1 year ago

Re: space, at least in the test suite, not necessarily production usage, in main_test.py, memory usage does go up 8%, from 34MB to 37MB on average.

john-kurkowski commented 1 year ago

Re: speed, using timeit and a hardcoded domain string, I see execution time go down 2-5% on CPython 3.11.

john-kurkowski commented 11 months ago

I want this change for future compatibility. I'm not seeing many downsides, besides the breaking change of no longer allowing accessing indexing and slicing tuple members, as there is no longer a tuple. This will be marked a breaking change.