dichoseek


Namedichoseek JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://github.com/tcosmo/dichoseek
SummaryPerforms binary search in binary files
upload_time2023-05-08 17:59:51
maintainer
docs_urlNone
authorTristan Sterin
requires_python
licenseMIT
keywords binary search
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Dichoseek

Dichoseek tests the membership of a n-byte encoded integer in a sorted binary file consisting of a succession of n-byte integers.

The name comes from the fact that the algorithm is a dichotomy (binary search) using the file `seek` function.

## Instal

`pip install dichoseek`

## Basic usage

Assuming that you are looking for a 4-byte unsigned integer (you can change this assumption):

```python
from dichoseek import dichoseek
elem = 124
is_elem_in_file = dichoseek("path/to/file", elem)
```

Or using a file object:

```python
from dichoseek import dichoseek
elem = 124
with open("path/to/file", "rb") as f:
  is_elem_in_file = dichoseek(f, elem)
```

## Other parameters

- `block_size`: number of bytes per integer. We assume that the size of the file is a multiple of this `block_size`. Default is `4`.

- `block_interpretation_function` is the function that is used to transform bytes into `int`. Default is unsigned, big-endian parsing: `lambda b: int.from_bytes(b, byteorder="big")`.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tcosmo/dichoseek",
    "name": "dichoseek",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "binary search",
    "author": "Tristan Sterin",
    "author_email": "tristan@prgm.dev",
    "download_url": "https://files.pythonhosted.org/packages/5a/f1/3989711c13f9e0b01828f71fc5a834404fcee6ef45802d2da6364fb709c8/dichoseek-0.2.3.tar.gz",
    "platform": null,
    "description": "# Dichoseek\n\nDichoseek tests the membership of a n-byte encoded integer in a sorted binary file consisting of a succession of n-byte integers.\n\nThe name comes from the fact that the algorithm is a dichotomy (binary search) using the file `seek` function.\n\n## Instal\n\n`pip install dichoseek`\n\n## Basic usage\n\nAssuming that you are looking for a 4-byte unsigned integer (you can change this assumption):\n\n```python\nfrom dichoseek import dichoseek\nelem = 124\nis_elem_in_file = dichoseek(\"path/to/file\", elem)\n```\n\nOr using a file object:\n\n```python\nfrom dichoseek import dichoseek\nelem = 124\nwith open(\"path/to/file\", \"rb\") as f:\n  is_elem_in_file = dichoseek(f, elem)\n```\n\n## Other parameters\n\n- `block_size`: number of bytes per integer. We assume that the size of the file is a multiple of this `block_size`. Default is `4`.\n\n- `block_interpretation_function` is the function that is used to transform bytes into `int`. Default is unsigned, big-endian parsing: `lambda b: int.from_bytes(b, byteorder=\"big\")`.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Performs binary search in binary files",
    "version": "0.2.3",
    "project_urls": {
        "Download": "https://github.com/tcosmo/dichoseek/archive/refs/tags/v0.2.2.tar.gz",
        "Homepage": "https://github.com/tcosmo/dichoseek"
    },
    "split_keywords": [
        "binary",
        "search"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5af13989711c13f9e0b01828f71fc5a834404fcee6ef45802d2da6364fb709c8",
                "md5": "7bac72b458937b5849dbeb80f5cb168e",
                "sha256": "3033a9f67f26fccbd49962235e5377c544aba890307b7a5bdc693b6c6f8277f1"
            },
            "downloads": -1,
            "filename": "dichoseek-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7bac72b458937b5849dbeb80f5cb168e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3501,
            "upload_time": "2023-05-08T17:59:51",
            "upload_time_iso_8601": "2023-05-08T17:59:51.207219Z",
            "url": "https://files.pythonhosted.org/packages/5a/f1/3989711c13f9e0b01828f71fc5a834404fcee6ef45802d2da6364fb709c8/dichoseek-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-08 17:59:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tcosmo",
    "github_project": "dichoseek",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dichoseek"
}
        
Elapsed time: 0.55623s