{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "Hexadecimal Hamming\n====================\n\n|Pip|_ |Prs|_ |Travis|_\n\n.. |Pip| image:: https://badge.fury.io/py/hexhamming.svg\n.. _Pip: https://badge.fury.io/py/hexhamming\n\n.. |Prs| image:: https://img.shields.io/badge/PRs-welcome-brightgreen.svg\n.. _Prs: .github/CONTRIBUTING.md#pull-requests\n\n.. |Travis| image:: https://travis-ci.org/mrecachinas/hexhamming.svg?branch=master\n.. _Travis: https://travis-ci.org/mrecachinas/hexhamming\n\nWhy yet another Hamming distance library?\n-----------------------------------------\n\nThere are a lot of fantastic (python) libraries that offer methods to calculate\nvarious edit distances, including Hamming distances: Distance, textdistance,\nscipy, jellyfish, etc.\n\nIn this case, I needed a hamming distance library that worked on hexadecimal\nstrings (i.e., a Python ``str``) and performed blazingly fast.\nFurthermore, I often did not care about hex strings greater than 256 bits.\nThat length constraint is different vs all the other libraries and enabled me\nto explore vectorization techniques via ``numba``, ``numpy``, and even\n``SSE/AVX``.\n\nLastly, I wanted to minimize dependencies, meaning you do not need to install\n``numpy``, ``gmpy``, ``cython``, ``pypy``, ``pythran``, etc.\n\nEventually, after playing around with ``gmpy.popcount``, ``numba.jit``,\n``pythran.run``, ``numpy``, and ``AVX2``, I decided to write what I wanted\nin a raw C++ header. Note: the only C++-feature I'm exploiting is C++ exceptions;\nwithout that, this could easily be C. At this point, I'm using raw ``char*`` and\n``int*``, so exploring re-writing this in Fortran makes little sense. Vectorization\ntechniques also ended up adding more overhead from data transfer between\nvector registers and normal registers; also, converting the hex strings to\nvector-register-ingestible floats from ``char*`` proved to have a non-trivial\noverhead.\n\nInstallation\n-------------\n\nTo install, ensure you have Python 2.7 or 3.4+. Run::\n\n pip install hexhamming\n\nor to install from source::\n\n git clone https://github.com/mrecachinas/hexhamming\n cd hexhamming\n python setup.py install # or pip install .\n\nIf you want to contribute to hexhamming, you should install the dev\ndependencies::\n\n pip install -r requirements-dev.txt\n\nand make sure the tests pass with::\n\n pytest # or tox -e py27,...\n\nExample\n-------\n\nTo use the base C++ extension, you can simply run::\n\n >>> from hexhamming import hamming_distance\n >>> hamming_distance('deadbeef', '00000000')\n 24\n\nTo use the lookup-based C++ extension, replace the above\n``hamming_distance`` with ``hamming_distance_lookup``.\n\nIf your machine supports the Intel SSE4/AVX2 instruction set,\nreplace the above ``hamming_distance`` with ``fast_hamming_distance``.\nNote: to use ``fast_hamming_distance``, your hex string must be 64\ncharacters or less (i.e., 256 bits or less).\n\nBenchmark\n---------\n\nBelow is a benchmark using ``pytest-benchmark`` on my early 2016 1.2 GHz Intel\nm5 8 GB 1867 MHz LPDDR3 macOS Mojave (10.14.3) with Python 2.7.15 and\nclang-1000.11.45.5.\n\n.. image:: https://github.com/mrecachinas/hexhamming/blob/master/docs/benchmark.png?raw=true\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mrecachinas/hex-hamming.git", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "hexhamming", "package_url": "https://pypi.org/project/hexhamming/", "platform": "", "project_url": "https://pypi.org/project/hexhamming/", "project_urls": { "Homepage": "https://github.com/mrecachinas/hex-hamming.git" }, "release_url": "https://pypi.org/project/hexhamming/1.0/", "requires_dist": null, "requires_python": "", "summary": "Fast Hamming distance calculation for hexadecimal strings", "version": "1.0" }, "last_serial": 4888099, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "f67d7c14a65a4c94a76941bf02f48908", "sha256": "e68803278f70b27793868a6fd682229b47711c729bee09032ce277ee551d50ee" }, "downloads": -1, "filename": "hexhamming-1.0-cp27-cp27m-macosx_10_13_x86_64.whl", "has_sig": false, "md5_digest": "f67d7c14a65a4c94a76941bf02f48908", "packagetype": "bdist_wheel", "python_version": "cp27", "requires_python": null, "size": 4685, "upload_time": "2019-03-02T11:30:46", "url": "https://files.pythonhosted.org/packages/d7/b6/57f9b5a076cefbf2c93e64e4de949f78e3e305acfde636ef743eef75eb71/hexhamming-1.0-cp27-cp27m-macosx_10_13_x86_64.whl" }, { "comment_text": "", "digests": { "md5": "161ac27d7baa0e81698749c295d70998", "sha256": "f5a2901a96cbf94e42ae3b4131a8956bda9a424f0c071914aa467a18c06cd169" }, "downloads": -1, "filename": "hexhamming-1.0-cp36-cp36m-macosx_10_13_x86_64.whl", "has_sig": false, "md5_digest": "161ac27d7baa0e81698749c295d70998", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 4765, "upload_time": "2019-03-02T11:30:01", "url": "https://files.pythonhosted.org/packages/56/51/219ecbce734dd51f887a64662f32d12e00e245ad78d48bfce29ea548b126/hexhamming-1.0-cp36-cp36m-macosx_10_13_x86_64.whl" }, { "comment_text": "", "digests": { "md5": "7d3c454d9a01c166558ad2eacd46cc07", "sha256": "acaaae3d3ddeb70855bf1b2fcf0e318c22d87b8d0eddb384fa136a72415dd5c7" }, "downloads": -1, "filename": "hexhamming-1.0.tar.gz", "has_sig": false, "md5_digest": "7d3c454d9a01c166558ad2eacd46cc07", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5115, "upload_time": "2019-03-02T11:30:03", "url": "https://files.pythonhosted.org/packages/01/29/616da57e6979629d0148a14cc9596a1f04c77c84994f4de52ae004b2a8ea/hexhamming-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f67d7c14a65a4c94a76941bf02f48908", "sha256": "e68803278f70b27793868a6fd682229b47711c729bee09032ce277ee551d50ee" }, "downloads": -1, "filename": "hexhamming-1.0-cp27-cp27m-macosx_10_13_x86_64.whl", "has_sig": false, "md5_digest": "f67d7c14a65a4c94a76941bf02f48908", "packagetype": "bdist_wheel", "python_version": "cp27", "requires_python": null, "size": 4685, "upload_time": "2019-03-02T11:30:46", "url": "https://files.pythonhosted.org/packages/d7/b6/57f9b5a076cefbf2c93e64e4de949f78e3e305acfde636ef743eef75eb71/hexhamming-1.0-cp27-cp27m-macosx_10_13_x86_64.whl" }, { "comment_text": "", "digests": { "md5": "161ac27d7baa0e81698749c295d70998", "sha256": "f5a2901a96cbf94e42ae3b4131a8956bda9a424f0c071914aa467a18c06cd169" }, "downloads": -1, "filename": "hexhamming-1.0-cp36-cp36m-macosx_10_13_x86_64.whl", "has_sig": false, "md5_digest": "161ac27d7baa0e81698749c295d70998", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 4765, "upload_time": "2019-03-02T11:30:01", "url": "https://files.pythonhosted.org/packages/56/51/219ecbce734dd51f887a64662f32d12e00e245ad78d48bfce29ea548b126/hexhamming-1.0-cp36-cp36m-macosx_10_13_x86_64.whl" }, { "comment_text": "", "digests": { "md5": "7d3c454d9a01c166558ad2eacd46cc07", "sha256": "acaaae3d3ddeb70855bf1b2fcf0e318c22d87b8d0eddb384fa136a72415dd5c7" }, "downloads": -1, "filename": "hexhamming-1.0.tar.gz", "has_sig": false, "md5_digest": "7d3c454d9a01c166558ad2eacd46cc07", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5115, "upload_time": "2019-03-02T11:30:03", "url": "https://files.pythonhosted.org/packages/01/29/616da57e6979629d0148a14cc9596a1f04c77c84994f4de52ae004b2a8ea/hexhamming-1.0.tar.gz" } ] }