{"id":13720684,"url":"https://github.com/TkTech/can_ada","last_synced_at":"2025-05-07T12:33:02.121Z","repository":{"id":166819378,"uuid":"642394027","full_name":"TkTech/can_ada","owner":"TkTech","description":"Python bindings for Ada, a fast and spec-compliant URL parser.","archived":false,"fork":false,"pushed_at":"2025-01-30T04:17:37.000Z","size":2259,"stargazers_count":135,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T00:11:36.662Z","etag":null,"topics":["python","url"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TkTech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"TkTech","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2023-05-18T13:20:04.000Z","updated_at":"2025-04-17T02:11:17.000Z","dependencies_parsed_at":"2024-03-16T17:16:54.491Z","dependency_job_id":"d4466be3-4c93-4e29-9f2c-3444aeae6158","html_url":"https://github.com/TkTech/can_ada","commit_stats":null,"previous_names":["tktech/can_ada"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TkTech%2Fcan_ada","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TkTech%2Fcan_ada/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TkTech%2Fcan_ada/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TkTech%2Fcan_ada/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TkTech","download_url":"https://codeload.github.com/TkTech/can_ada/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252876677,"owners_count":21818224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","url"],"created_at":"2024-08-03T01:01:06.868Z","updated_at":"2025-05-07T12:33:02.112Z","avatar_url":"https://github.com/TkTech.png","language":"C++","funding_links":["https://github.com/sponsors/TkTech"],"categories":["C++"],"sub_categories":[],"readme":"# can_ada\n\n[Fast] Python bindings for [Ada][], a fast and WHATWG spec-compliant URL parser.\nThis is the URL parser used in projects like Node.js.\n\n## Installation\n\n```bash\npip install can_ada\n```\n\nBinary wheels are available for most platforms. If not available, a\nC++17-or-greater compiler will be required to build the underlying Ada library.\n\n##  WHATWG URL compliance\n\nUnlike the standard library's `urllib.parse` module, this library is compliant with the WHATWG URL specification.\n\n```python\nimport can_ada\nurlstring = \"https://www.GOoglé.com/./path/../path2/\"\nurl = can_ada.parse(urlstring)\n# prints www.xn--googl-fsa.com, the correctly parsed domain name according\n# to WHATWG\nprint(url.hostname)\n# prints /path2/, which is the correctly parsed pathname according to WHATWG\nprint(url.pathname)\n\nimport urllib.parse\nurlstring = \"https://www.GOoglé.com/./path/../path2/\"\nurl = urllib.parse.urlparse(urlstring)\n# prints www.googlé.com\nprint(url.hostname)\n# prints /./path/../path2/\nprint(url.path)\n```\n\n## Usage\n\nParsing is simple:\n\n```python\nfrom can_ada import parse\n\nurl = parse(\"https://tkte.ch/search?q=canada\")\nprint(url.protocol) # https:\nprint(url.host) # tkte.ch\nprint(url.pathname) # /search\nprint(url.search) # ?q=canada\n```\n\nYou can also modify URLs:\n\n```python\nfrom can_ada import parse\n\nurl = parse(\"https://tkte.ch/search?q=canada\")\nurl.host = \"google.com\"\nurl.search = \"?q=canada\u0026safe=off\"\nprint(url) # https://google.com/search?q=canada\u0026safe=off\n```\n\n`can_ada` also supports the `URLSearchParams` API:\n\n```python\nfrom can_ada import URLSearchParams\n\nparams = URLSearchParams(\"q=canada\u0026safe=off\")\nparams.append(\"page\", \"2\")\nparams.append(\"page\", \"3\")\nparams[\"q\"] = \"usa\"\nprint(params) # q=usa\u0026safe=off\u0026page=2\u0026page=3\nprint(params.has(\"q\")) # True\nprint(params.get(\"page\")) # 2\nprint(params.get_all(\"page\")) # [2, 3]\nprint(params.keys()) # [\"q\", \"safe\", \"page\"]\nprint(params.values()) # [\"usa\", \"off\", \"2\", \"3\"]\n```\n\n## Performance\n\nWe find that `can_ada` is typically ~4x faster than urllib:\n\n```\n---------------------------------------------------------------------------------\nName (time in ms)              Min                 Max                Mean       \n---------------------------------------------------------------------------------\ntest_can_ada_parse         54.1304 (1.0)       54.6734 (1.0)       54.3699 (1.0) \ntest_ada_python_parse     107.5653 (1.99)     108.1666 (1.98)     107.7817 (1.98)\ntest_urllib_parse         251.5167 (4.65)     255.1327 (4.67)     253.2407 (4.66)\n---------------------------------------------------------------------------------\n```\n\nTo run the benchmarks locally, use:\n\n```\npytest --runslow\n```\n\n[Ada]: https://ada-url.com/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTkTech%2Fcan_ada","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTkTech%2Fcan_ada","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTkTech%2Fcan_ada/lists"}