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 goto choice to quote and unquote URLs. However, should quoting / unquoting 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 python version. For linux the wheel has to be build against a libc with a version older or equal to the version of libc on the platform the wheel will be executed on.

Installation

pip install urlquote

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

Encoding

All ASCII characters less than hexidecimal 20 and greater than 7E are encoded. This includes special charcters such as line feed, carriage return, NULL, etc. . Aside from these, space, double quote (") , hash (#), inequality qualifiers (<), (>), backtick (`), question mark (?), and curly brackets ({), (}) are also encoded.

Development

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

To build it you need to install rust and cargo. You can than 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

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.0.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distributions

urlquote-1.0.0-py2.py3-none-win32.whl (65.3 kB view details)

Uploaded Python 2 Python 3 Windows x86

urlquote-1.0.0-py2.py3-none-manylinux1_x86_64.whl (698.5 kB view details)

Uploaded Python 2 Python 3

urlquote-1.0.0-py2.py3-none-macosx_10_6_intel.whl (96.7 kB view details)

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

File details

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

File metadata

  • Download URL: urlquote-1.0.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

File hashes

Hashes for urlquote-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bba470986c04b0edf73da57022d797e9d44fdfc873f640b3f488c37964604578
MD5 4c884156da2d0c6ed2c20b74880aa7e5
BLAKE2b-256 c1435cb6f21e09d4a371a8d0e31153783fb583a1f4fbe9ab0adfdf024fc6c3f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: urlquote-1.0.0-py2.py3-none-win32.whl
  • Upload date:
  • Size: 65.3 kB
  • Tags: Python 2, Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.2

File hashes

Hashes for urlquote-1.0.0-py2.py3-none-win32.whl
Algorithm Hash digest
SHA256 e2f82c30c31e304a97c06ebe2f8c8246682dc11d9b7c51b136c4aab224eb61e6
MD5 4afcaf33ab3b1cbdf6fee625fba600cf
BLAKE2b-256 4c7d77294accc5a095ecb9ca55039c1438ab2f8af0b2384f0188c232bd6eb8ee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: urlquote-1.0.0-py2.py3-none-manylinux1_x86_64.whl
  • Upload date:
  • Size: 698.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

File hashes

Hashes for urlquote-1.0.0-py2.py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0e4437c14ccd99bfb74f25b911fd198988a2482ecbd51db6bac95af9dd2d4d8e
MD5 2167f99936e465550916024880471a6e
BLAKE2b-256 44ce1f2c441fee0baa927cfa5b75d73686535417743d5ee71362ec41a4bcda98

See more details on using hashes here.

File details

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

File metadata

  • Download URL: urlquote-1.0.0-py2.py3-none-macosx_10_6_intel.whl
  • Upload date:
  • Size: 96.7 kB
  • Tags: Python 2, Python 3, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.1

File hashes

Hashes for urlquote-1.0.0-py2.py3-none-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 76cfaace82ac844d440c656115172ae723791381252487484fa16270bada7f5c
MD5 7090a96d99724555ff492d9e9e13f179
BLAKE2b-256 9129f573edd7d14a434057be98aafa97bcbb2e0958c378fef0a1af6f88bf5408

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