René's URL Explorer Experiment


Title: Remove __eq__ and __hash__ in 2.0; compare names via explicit methods · Issue #223 · derek73/python-nameparser · GitHub

Open Graph Title: Remove __eq__ and __hash__ in 2.0; compare names via explicit methods · Issue #223 · derek73/python-nameparser

X Title: Remove __eq__ and __hash__ in 2.0; compare names via explicit methods · Issue #223 · derek73/python-nameparser

Description: Summary 2.0 will remove HumanName.__eq__ and HumanName.__hash__. Instances revert to Python's default identity semantics (still safely usable in sets/dicts — see below). Value comparison moves to two explicit methods, shipped in 1.3.0 so...

Open Graph Description: Summary 2.0 will remove HumanName.__eq__ and HumanName.__hash__. Instances revert to Python's default identity semantics (still safely usable in sets/dicts — see below). Value comparison moves to t...

X Description: Summary 2.0 will remove HumanName.__eq__ and HumanName.__hash__. Instances revert to Python's default identity semantics (still safely usable in sets/dicts — see below). Value comparison moves ...

Opengraph URL: https://github.com/derek73/python-nameparser/issues/223

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Remove __eq__ and __hash__ in 2.0; compare names via explicit methods","articleBody":"## Summary\n\n2.0 will remove `HumanName.__eq__` and `HumanName.__hash__`. Instances revert to Python's default identity semantics (still safely usable in sets/dicts — see below). Value comparison moves to two explicit methods, shipped in 1.3.0 so the APIs overlap for a full minor release: `matches()` and `comparison_key()` (added in PR #247).\n\nFeedback welcome — this is a breaking change and the rationale is laid out in full below. The deprecation warnings shipped in 1.3.0 (#224, implemented in PR #247; released).\n\n## Why the current design can't be fixed in place\n\n`__eq__` currently compares `str(self).lower()` against `str(other).lower()`, and `__hash__` (added in 1.2.0, #138) hashes that string. This makes three promises:\n\n1. **Case-insensitive** equality\n2. **Cross-type** equality with plain strings (`hn == \"John Smith\"` → True)\n3. **Hashability** (usable in sets/dicts)\n\nThese are mathematically incompatible. If `hn == \"John Smith\"` and `hn == \"john smith\"` are both True, the hash invariant (`a == b` ⇒ `hash(a) == hash(b)`) requires `hash(hn)` to equal two different values. Consequence today: `{hn} | {\"John Smith\"}` is a two-element set whose elements compare equal — broken dedup, the very use case #138 added hashing for. No implementation can fix this; one of the three promises has to go.\n\n## Additional defects in the current design\n\n- **Mutation strands container entries.** `HumanName` is mutable; assigning any attribute changes the hash, so an instance already in a set/dict becomes unfindable. (Python nulls `__hash__` when a class defines `__eq__` for exactly this reason — #138 re-enabled what the language had disabled.)\n- **Equality depends on display config.** `str(self)` goes through `string_format`, so changing `CONSTANTS.string_format` retroactively changes whether two existing objects are equal. Same class of shared-mutable-state problem as #222.\n- **`maiden` is invisible to equality** — the default `string_format` has no `{maiden}` placeholder.\n- **`hn == 42` can be True** (if the name is \"42\"); `__eq__` stringifies any operand instead of returning `NotImplemented`.\n\n## Why removal rather than component-based `__eq__`/`__hash__`\n\nA component-based `==` was considered and is workable, but it still privileges one equality semantic for a domain that has none (is \"J. Smith\" equal to \"John Smith\"? \"Smith, John\"? every application answers differently), and still carries the mutate-while-hashed caveat. Removing both dunders is the only option with no footguns left: default identity hash is always stable and always consistent with identity equality, so sets/dicts of HumanName keep working — they just mean \"these objects\" rather than \"these name values\". Value semantics become explicit:\n\n- `hn.matches(other)` — parses a string operand, compares parsed components\n- `hn.comparison_key()` — hashable tuple of components, for dedup/dicts/groupby\n\n## Migration (from 1.3.0's deprecated `==`)\n\n| Before | After |\n|---|---|\n| `hn == x` | `hn.matches(x)` |\n| `\"john smith\" == hn` (reflected) | `hn.matches(\"john smith\")` — must flip operands |\n| `hn == maybe_none` | `maybe_none is not None and hn.matches(maybe_none)` — `matches()` raises `TypeError` on non-`str`/`HumanName` |\n| `hn in names`, `.index()`, `assertIn` | `any(hn.matches(n) for n in names)` or `comparison_key()` sets |\n| set/dict dedup via `hash(hn)` | `{n.comparison_key(): n for n in names}.values()` |\n\nUsers with a lossy custom `string_format` (e.g. `\"{first} {last}\"`) currently get projection equality; `matches()` compares all components and is stricter. Compare the specific attributes instead.\n\n## Checklist\n\n- [ ] Remove `__eq__` and `__hash__` from `HumanName`\n- [ ] Replace equality/hash tests with identity-semantics tests\n- [ ] Update the `docs/usage.rst` deprecation note (the equality example already uses `matches()` as of 1.3.0)\n- [ ] Migration section in docs + release log entry\n\n\n","author":{"url":"https://github.com/derek73","@type":"Person","name":"derek73"},"datePublished":"2026-07-05T20:56:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/223/python-nameparser/issues/223"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b4e2a323-a3d6-0545-0a88-decf15b803c4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBAD6:324367:2375810:339763D:6A566116
html-safe-nonce4375248aa10a7b2bbb07e77ca6b67cab1655a92e64dea6d45e040fb8a842ab10
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQUQ2OjMyNDM2NzoyMzc1ODEwOjMzOTc2M0Q6NkE1NjYxMTYiLCJ2aXNpdG9yX2lkIjoiNjc1MDQ2NjA1ODcyMDAxMDUxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac8b5c350b0e1049fbd9905a953f576130aec20f7b62ba985556339cd949bf48cf
hovercard-subject-tagissue:4814410809
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/derek73/python-nameparser/223/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6b16af349dfcd60c98a743a5deee658ff3f89c446e70593dd3ab37345ffa67ca/derek73/python-nameparser/issues/223
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6b16af349dfcd60c98a743a5deee658ff3f89c446e70593dd3ab37345ffa67ca/derek73/python-nameparser/issues/223
og:image:altSummary 2.0 will remove HumanName.__eq__ and HumanName.__hash__. Instances revert to Python's default identity semantics (still safely usable in sets/dicts — see below). Value comparison moves to t...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamederek73
hostnamegithub.com
expected-hostnamegithub.com
None6a3afe34dff341ad10912db44becf282289d7f2af20576241738530fbb28de01
turbo-cache-controlno-preview
go-importgithub.com/derek73/python-nameparser git https://github.com/derek73/python-nameparser.git
octolytics-dimension-user_id18306
octolytics-dimension-user_loginderek73
octolytics-dimension-repository_id18353524
octolytics-dimension-repository_nwoderek73/python-nameparser
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id18353524
octolytics-dimension-repository_network_root_nwoderek73/python-nameparser
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseb71002134df95575e9f6c2945a64d454b0be181e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/derek73/python-nameparser/issues/223#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fderek73%2Fpython-nameparser%2Fissues%2F223
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fderek73%2Fpython-nameparser%2Fissues%2F223
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=derek73%2Fpython-nameparser
Reloadhttps://github.com/derek73/python-nameparser/issues/223
Reloadhttps://github.com/derek73/python-nameparser/issues/223
Reloadhttps://github.com/derek73/python-nameparser/issues/223
derek73 https://github.com/derek73
python-nameparserhttps://github.com/derek73/python-nameparser
Notifications https://github.com/login?return_to=%2Fderek73%2Fpython-nameparser
Fork 111 https://github.com/login?return_to=%2Fderek73%2Fpython-nameparser
Star 711 https://github.com/login?return_to=%2Fderek73%2Fpython-nameparser
Code https://github.com/derek73/python-nameparser
Issues 22 https://github.com/derek73/python-nameparser/issues
Pull requests 2 https://github.com/derek73/python-nameparser/pulls
Actions https://github.com/derek73/python-nameparser/actions
Projects https://github.com/derek73/python-nameparser/projects
Wiki https://github.com/derek73/python-nameparser/wiki
Security and quality 0 https://github.com/derek73/python-nameparser/security
Insights https://github.com/derek73/python-nameparser/pulse
Code https://github.com/derek73/python-nameparser
Issues https://github.com/derek73/python-nameparser/issues
Pull requests https://github.com/derek73/python-nameparser/pulls
Actions https://github.com/derek73/python-nameparser/actions
Projects https://github.com/derek73/python-nameparser/projects
Wiki https://github.com/derek73/python-nameparser/wiki
Security and quality https://github.com/derek73/python-nameparser/security
Insights https://github.com/derek73/python-nameparser/pulse
Remove __eq__ and __hash__ in 2.0; compare names via explicit methodshttps://github.com/derek73/python-nameparser/issues/223#top
https://github.com/derek73
breaking-changeBackwards-incompatible API changehttps://github.com/derek73/python-nameparser/issues?q=state%3Aopen%20label%3A%22breaking-change%22
enhancementhttps://github.com/derek73/python-nameparser/issues?q=state%3Aopen%20label%3A%22enhancement%22
v2.0https://github.com/derek73/python-nameparser/milestone/35
https://github.com/derek73
derek73https://github.com/derek73
on Jul 5, 2026https://github.com/derek73/python-nameparser/issues/223#issue-4814410809
#247https://github.com/derek73/python-nameparser/pull/247
#224https://github.com/derek73/python-nameparser/issues/224
#247https://github.com/derek73/python-nameparser/pull/247
#138https://github.com/derek73/python-nameparser/pull/138
#138https://github.com/derek73/python-nameparser/pull/138
Make HumanName objects hashable #138https://github.com/derek73/python-nameparser/pull/138
Stop parsing from mutating the Constants it reads #222https://github.com/derek73/python-nameparser/pull/222
derek73https://github.com/derek73
breaking-changeBackwards-incompatible API changehttps://github.com/derek73/python-nameparser/issues?q=state%3Aopen%20label%3A%22breaking-change%22
enhancementhttps://github.com/derek73/python-nameparser/issues?q=state%3Aopen%20label%3A%22enhancement%22
v2.0No due datehttps://github.com/derek73/python-nameparser/milestone/35
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.