Skip to main content

Ada is a fast spec-compliant url parser

Project description

can_ada

[Fast] Python bindings for Ada, a fast and WHATWG spec-compliant URL parser. This is the URL parser used in projects like Node.js.

Installation

pip install can_ada

Binary wheels are available for most platforms. If not available, a C++17-or-greater compiler will be required to build the underlying Ada library.

WHATWG URL compliance

Unlike the standard library's urllib.parse module, this library is compliant with the WHATWG URL specification.

import can_ada
urlstring = "https://www.GOoglé.com/./path/../path2/"
url = can_ada.parse(urlstring)
# prints www.xn--googl-fsa.com, the correctly parsed domain name according
# to WHATWG
print(url.hostname)
# prints /path2/, which is the correctly parsed pathname according to WHATWG
print(url.pathname)

import urllib.parse
urlstring = "https://www.GOoglé.com/./path/../path2/"
url = urllib.parse.urlparse(urlstring)
# prints www.googlé.com
print(url.hostname)
# prints /./path/../path2/
print(url.path)

Usage

Parsing is simple:

from can_ada import parse

url = parse("https://tkte.ch/search?q=canada")
print(url.protocol) # https:
print(url.host) # tkte.ch
print(url.pathname) # /search
print(url.search) # ?q=canada

You can also modify URLs:

from can_ada import parse

url = parse("https://tkte.ch/search?q=canada")
url.host = "google.com"
url.search = "?q=canada&safe=off"
print(url) # https://google.com/search?q=canada&safe=off

Performance

We find that can_ada is typically ~4x faster than urllib:

---------------------------------------------------------------------------------
Name (time in ms)              Min                 Max                Mean       
---------------------------------------------------------------------------------
test_can_ada_parse         54.1304 (1.0)       54.6734 (1.0)       54.3699 (1.0) 
test_ada_python_parse     107.5653 (1.99)     108.1666 (1.98)     107.7817 (1.98)
test_urllib_parse         251.5167 (4.65)     255.1327 (4.67)     253.2407 (4.66)
---------------------------------------------------------------------------------

To run the benchmarks locally, use:

pytest --runslow

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

can_ada-1.3.0.tar.gz (166.7 kB view hashes)

Uploaded Source

Built Distributions

can_ada-1.3.0-pp39-pypy39_pp73-win_amd64.whl (224.7 kB view hashes)

Uploaded PyPy Windows x86-64

can_ada-1.3.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (315.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

can_ada-1.3.0-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (337.5 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686

can_ada-1.3.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (312.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

can_ada-1.3.0-pp39-pypy39_pp73-macosx_10_15_x86_64.whl (277.7 kB view hashes)

Uploaded PyPy macOS 10.15+ x86-64

can_ada-1.3.0-pp38-pypy38_pp73-win_amd64.whl (224.7 kB view hashes)

Uploaded PyPy Windows x86-64

can_ada-1.3.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (316.7 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

can_ada-1.3.0-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (337.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686

can_ada-1.3.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (312.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

can_ada-1.3.0-pp38-pypy38_pp73-macosx_10_15_x86_64.whl (277.7 kB view hashes)

Uploaded PyPy macOS 10.15+ x86-64

can_ada-1.3.0-pp37-pypy37_pp73-win_amd64.whl (224.6 kB view hashes)

Uploaded PyPy Windows x86-64

can_ada-1.3.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (317.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

can_ada-1.3.0-pp37-pypy37_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (338.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686

can_ada-1.3.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (312.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

can_ada-1.3.0-pp37-pypy37_pp73-macosx_10_15_x86_64.whl (277.3 kB view hashes)

Uploaded PyPy macOS 10.15+ x86-64

can_ada-1.3.0-cp312-cp312-win_amd64.whl (226.2 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

can_ada-1.3.0-cp312-cp312-win32.whl (205.0 kB view hashes)

Uploaded CPython 3.12 Windows x86

can_ada-1.3.0-cp312-cp312-musllinux_1_1_x86_64.whl (850.0 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

can_ada-1.3.0-cp312-cp312-musllinux_1_1_s390x.whl (916.0 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ s390x

can_ada-1.3.0-cp312-cp312-musllinux_1_1_ppc64le.whl (906.5 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ ppc64le

can_ada-1.3.0-cp312-cp312-musllinux_1_1_i686.whl (921.9 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ i686

can_ada-1.3.0-cp312-cp312-musllinux_1_1_aarch64.whl (837.8 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ ARM64

can_ada-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (335.9 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

can_ada-1.3.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl (342.1 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ s390x

can_ada-1.3.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (361.2 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ppc64le

can_ada-1.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (359.8 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ i686

can_ada-1.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (327.2 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

can_ada-1.3.0-cp312-cp312-macosx_11_0_arm64.whl (271.7 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

can_ada-1.3.0-cp312-cp312-macosx_10_15_x86_64.whl (280.9 kB view hashes)

Uploaded CPython 3.12 macOS 10.15+ x86-64

can_ada-1.3.0-cp312-cp312-macosx_10_15_universal2.whl (548.3 kB view hashes)

Uploaded CPython 3.12 macOS 10.15+ universal2 (ARM64, x86-64)

can_ada-1.3.0-cp311-cp311-win_amd64.whl (226.4 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

can_ada-1.3.0-cp311-cp311-win32.whl (205.7 kB view hashes)

Uploaded CPython 3.11 Windows x86

can_ada-1.3.0-cp311-cp311-musllinux_1_1_x86_64.whl (850.6 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

can_ada-1.3.0-cp311-cp311-musllinux_1_1_s390x.whl (915.3 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ s390x

can_ada-1.3.0-cp311-cp311-musllinux_1_1_ppc64le.whl (906.5 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ ppc64le

can_ada-1.3.0-cp311-cp311-musllinux_1_1_i686.whl (922.2 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

can_ada-1.3.0-cp311-cp311-musllinux_1_1_aarch64.whl (838.6 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ ARM64

can_ada-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (336.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

can_ada-1.3.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl (343.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ s390x

can_ada-1.3.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (364.2 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ppc64le

can_ada-1.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (359.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

can_ada-1.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (327.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

can_ada-1.3.0-cp311-cp311-macosx_11_0_arm64.whl (272.8 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

can_ada-1.3.0-cp311-cp311-macosx_10_15_x86_64.whl (280.8 kB view hashes)

Uploaded CPython 3.11 macOS 10.15+ x86-64

can_ada-1.3.0-cp311-cp311-macosx_10_15_universal2.whl (549.5 kB view hashes)

Uploaded CPython 3.11 macOS 10.15+ universal2 (ARM64, x86-64)

can_ada-1.3.0-cp310-cp310-win_amd64.whl (225.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

can_ada-1.3.0-cp310-cp310-win32.whl (204.7 kB view hashes)

Uploaded CPython 3.10 Windows x86

can_ada-1.3.0-cp310-cp310-musllinux_1_1_x86_64.whl (849.8 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

can_ada-1.3.0-cp310-cp310-musllinux_1_1_s390x.whl (914.4 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ s390x

can_ada-1.3.0-cp310-cp310-musllinux_1_1_ppc64le.whl (905.4 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ ppc64le

can_ada-1.3.0-cp310-cp310-musllinux_1_1_i686.whl (921.2 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

can_ada-1.3.0-cp310-cp310-musllinux_1_1_aarch64.whl (837.5 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ ARM64

can_ada-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (334.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

can_ada-1.3.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl (341.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ s390x

can_ada-1.3.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (362.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ppc64le

can_ada-1.3.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (358.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

can_ada-1.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (327.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

can_ada-1.3.0-cp310-cp310-macosx_11_0_arm64.whl (271.5 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

can_ada-1.3.0-cp310-cp310-macosx_10_15_x86_64.whl (279.6 kB view hashes)

Uploaded CPython 3.10 macOS 10.15+ x86-64

can_ada-1.3.0-cp310-cp310-macosx_10_15_universal2.whl (546.9 kB view hashes)

Uploaded CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64)

can_ada-1.3.0-cp39-cp39-win_amd64.whl (223.2 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

can_ada-1.3.0-cp39-cp39-win32.whl (204.9 kB view hashes)

Uploaded CPython 3.9 Windows x86

can_ada-1.3.0-cp39-cp39-musllinux_1_1_x86_64.whl (849.9 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

can_ada-1.3.0-cp39-cp39-musllinux_1_1_s390x.whl (914.5 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ s390x

can_ada-1.3.0-cp39-cp39-musllinux_1_1_ppc64le.whl (905.6 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ ppc64le

can_ada-1.3.0-cp39-cp39-musllinux_1_1_i686.whl (921.2 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

can_ada-1.3.0-cp39-cp39-musllinux_1_1_aarch64.whl (837.9 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ ARM64

can_ada-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (335.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

can_ada-1.3.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl (341.9 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ s390x

can_ada-1.3.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (363.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ppc64le

can_ada-1.3.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (359.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

can_ada-1.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (327.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

can_ada-1.3.0-cp39-cp39-macosx_11_0_arm64.whl (271.7 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

can_ada-1.3.0-cp39-cp39-macosx_10_15_x86_64.whl (279.8 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

can_ada-1.3.0-cp39-cp39-macosx_10_15_universal2.whl (547.2 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ universal2 (ARM64, x86-64)

can_ada-1.3.0-cp38-cp38-win_amd64.whl (225.4 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

can_ada-1.3.0-cp38-cp38-win32.whl (204.6 kB view hashes)

Uploaded CPython 3.8 Windows x86

can_ada-1.3.0-cp38-cp38-musllinux_1_1_x86_64.whl (849.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

can_ada-1.3.0-cp38-cp38-musllinux_1_1_s390x.whl (914.0 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ s390x

can_ada-1.3.0-cp38-cp38-musllinux_1_1_ppc64le.whl (905.1 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ ppc64le

can_ada-1.3.0-cp38-cp38-musllinux_1_1_i686.whl (920.7 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

can_ada-1.3.0-cp38-cp38-musllinux_1_1_aarch64.whl (837.5 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ ARM64

can_ada-1.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (334.8 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

can_ada-1.3.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl (341.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ s390x

can_ada-1.3.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (362.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ppc64le

can_ada-1.3.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (358.8 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

can_ada-1.3.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (326.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

can_ada-1.3.0-cp38-cp38-macosx_11_0_arm64.whl (271.4 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

can_ada-1.3.0-cp38-cp38-macosx_10_15_x86_64.whl (279.4 kB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

can_ada-1.3.0-cp38-cp38-macosx_10_15_universal2.whl (546.7 kB view hashes)

Uploaded CPython 3.8 macOS 10.15+ universal2 (ARM64, x86-64)

can_ada-1.3.0-cp37-cp37m-win_amd64.whl (225.7 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

can_ada-1.3.0-cp37-cp37m-win32.whl (205.0 kB view hashes)

Uploaded CPython 3.7m Windows x86

can_ada-1.3.0-cp37-cp37m-musllinux_1_1_x86_64.whl (852.4 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

can_ada-1.3.0-cp37-cp37m-musllinux_1_1_s390x.whl (919.2 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ s390x

can_ada-1.3.0-cp37-cp37m-musllinux_1_1_ppc64le.whl (910.4 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ ppc64le

can_ada-1.3.0-cp37-cp37m-musllinux_1_1_i686.whl (926.0 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ i686

can_ada-1.3.0-cp37-cp37m-musllinux_1_1_aarch64.whl (841.6 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ ARM64

can_ada-1.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (337.5 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

can_ada-1.3.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl (344.7 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ s390x

can_ada-1.3.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (365.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ppc64le

can_ada-1.3.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl (363.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686

can_ada-1.3.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (329.3 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

can_ada-1.3.0-cp37-cp37m-macosx_10_15_x86_64.whl (278.5 kB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page