Skip to main content

Fast quoting and unquoting of urls.

Project description

Urlquote

Fast percent encoding / decoding for python.

This library is not intended to be a replacement for urllib. urllib is part of the Python standard library and should be your go-to choice to quote and unquote URLs. However, should quoting or unquoting of URLs be known to be a performance bottleneck and you are fine with the encoding described below, then by all means have fun using this library.

Usage

from urlquote import quote

quoted = quote('/El Niño/')
assert(quoted == '/El%20Ni%C3%B1o/'.encode('utf-8'))

Compatibility

Since this library uses a cffi interface it should work fine with any version of Python. For Linux the wheel has to be build against a version of libc older or equal to the version of libc on the platform the wheel will be used on.

Installation

pip install urlquote

quote operates on UTF-8-encoded bytes. If passed a string, it will encode it into UTF-8 first. It will always return UTF-8-encoded bytes. unquote behaves the same way.

Encoding

The following encodings are offered. DEFAULT_QUOTING is used in case the quoting parameter is not specified.

Name Additional encoded characters
SIMPLE_QUOTING
DEFAULT_QUOTING space, <,>,`,?,{,}
QUERY_QUOTING space, ",#,<,>
PATH_SEGMENT_QUOTING space, ",#,<,>,`,?,%,/
USERINFO_QUOTING space, ",#,<,>,`,?,{,},/,:,;,=,@,\,[,],^,|
PYTHON_3_7_QUOTING space, ",#,<,>,`,?,{,},$,%,&,\,(,),,,=,;,:,!,@,[,],^,|,+,*

Non printable and non standard ASCII characters are always quoted. The PYTHON_3_7_QUOTING is going to work the same way in every Python version the name is only refering to the urllib default encoding used in Python 3.7.

Development

This library is a thin wrapper around the Rust crate percent-encoding. It exposes part of its functionality to python via a C interface using milksnake.

To build it you need to install Rust and Cargo. Than you can proceed to build the wheel with:

python setup.py build sdist bdist_wheel

To execute the Python tests use:

pip install -e .
pytest test.py

There are also some Rust-only unit tests. To execute them change into the rust subdirectory and call.

cargo test

With the nightly toolchain installed you may also call the Rust-only benchmarks using:

cargo +nightly bench

Links

Support

This tool is provided as is under an MIT license without any warranty or SLA. You are free to use it as part for any purpose, but the responsibility for operating it resides with you. We appreciate your feedback though. Contributions on GitHub are welcome.

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

urlquote-1.1.3.tar.gz (22.9 kB view details)

Uploaded Source

Built Distributions

urlquote-1.1.3-py2.py3-none-win32.whl (72.9 kB view details)

Uploaded Python 2 Python 3 Windows x86

urlquote-1.1.3-py2.py3-none-manylinux2010_x86_64.whl (603.2 kB view details)

Uploaded Python 2 Python 3 manylinux: glibc 2.12+ x86-64

urlquote-1.1.3-py2.py3-none-manylinux1_x86_64.whl (603.2 kB view details)

Uploaded Python 2 Python 3

urlquote-1.1.3-py2.py3-none-macosx_10_6_intel.whl (95.9 kB view details)

Uploaded Python 2 Python 3 macOS 10.6+ Intel (x86-64, i386)

File details

Details for the file urlquote-1.1.3.tar.gz.

File metadata

  • Download URL: urlquote-1.1.3.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.1

File hashes

Hashes for urlquote-1.1.3.tar.gz
Algorithm Hash digest
SHA256 7b961aced6d749cac738c84748acf5fa236a1311d3805ecce58ef397a040fd96
MD5 ff0c3431138e378389250099ffcd2ed5
BLAKE2b-256 f837b21dc41f69d64dcae77e7ba8318df050ba433cbacd9ef2ed41427aa28b15

See more details on using hashes here.

File details

Details for the file urlquote-1.1.3-py2.py3-none-win32.whl.

File metadata

  • Download URL: urlquote-1.1.3-py2.py3-none-win32.whl
  • Upload date:
  • Size: 72.9 kB
  • Tags: Python 2, Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for urlquote-1.1.3-py2.py3-none-win32.whl
Algorithm Hash digest
SHA256 bd0f8f16a63ef687db1c3d48281e43e5b1992bcd104bf9977ced6cca492cdeb2
MD5 ba86d01d24542f2af72d764ee3c2c5f2
BLAKE2b-256 4182f878d73608cb1f83ca742bb5526261b7d8b1716a5ca1cb95f3ec33a42502

See more details on using hashes here.

File details

Details for the file urlquote-1.1.3-py2.py3-none-manylinux2010_x86_64.whl.

File metadata

  • Download URL: urlquote-1.1.3-py2.py3-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 603.2 kB
  • Tags: Python 2, Python 3, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.1

File hashes

Hashes for urlquote-1.1.3-py2.py3-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 8d0c00cbccf026eaf719c05731ebca1bc6d1ae945c0bf25472c7ecd919bbccc4
MD5 02159da0f2457c2226c28b1eafb65df8
BLAKE2b-256 550f50e8a046e3787347ab860f5823108437360d462eaab4cb8d216f3e1922e5

See more details on using hashes here.

File details

Details for the file urlquote-1.1.3-py2.py3-none-manylinux1_x86_64.whl.

File metadata

  • Download URL: urlquote-1.1.3-py2.py3-none-manylinux1_x86_64.whl
  • Upload date:
  • Size: 603.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.1

File hashes

Hashes for urlquote-1.1.3-py2.py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7db711106d20724470c3f093bd2edbfd046866686859e8d26ea8baa9a0768eab
MD5 b84ea54f42e7abe9f95f089bc9508e93
BLAKE2b-256 d17578fbaa55ee790919426bd4282629dceb69d917c9ef63e909a4b3a0ce84b5

See more details on using hashes here.

File details

Details for the file urlquote-1.1.3-py2.py3-none-macosx_10_6_intel.whl.

File metadata

  • Download URL: urlquote-1.1.3-py2.py3-none-macosx_10_6_intel.whl
  • Upload date:
  • Size: 95.9 kB
  • Tags: Python 2, Python 3, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.1

File hashes

Hashes for urlquote-1.1.3-py2.py3-none-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 a3181bd1d6a52843fef0b8eb77620ce93daa83c956dabf6ee347f5dd81911388
MD5 a3e060c14f1064a5c7f2bc6cbb372160
BLAKE2b-256 233f95b72adcfdbf8092f82f36129bb60656d40fc5385f1c1e8f25af8ee68b61

See more details on using hashes here.

Supported by

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