{"id":28066807,"url":"https://github.com/grantjenks/python-arraydeque","last_synced_at":"2025-08-13T21:43:25.293Z","repository":{"id":275353410,"uuid":"925798864","full_name":"grantjenks/python-arraydeque","owner":"grantjenks","description":"ArrayDeque is a fast, array-backed deque implementation for Python written in C.","archived":false,"fork":false,"pushed_at":"2025-03-29T22:37:23.000Z","size":226,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T03:39:02.570Z","etag":null,"topics":["c","data-type","deque","performance","python"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grantjenks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-01T19:18:32.000Z","updated_at":"2025-04-13T16:50:22.000Z","dependencies_parsed_at":"2025-02-01T22:25:13.103Z","dependency_job_id":"67cbd671-9c66-4728-bfc6-cd41b7173a58","html_url":"https://github.com/grantjenks/python-arraydeque","commit_stats":null,"previous_names":["grantjenks/python-arraydeque"],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grantjenks%2Fpython-arraydeque","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grantjenks%2Fpython-arraydeque/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grantjenks%2Fpython-arraydeque/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grantjenks%2Fpython-arraydeque/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grantjenks","download_url":"https://codeload.github.com/grantjenks/python-arraydeque/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253770422,"owners_count":21961769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","data-type","deque","performance","python"],"created_at":"2025-05-12T15:54:49.428Z","updated_at":"2025-05-12T15:54:50.272Z","avatar_url":"https://github.com/grantjenks.png","language":"C","readme":"# ArrayDeque\n\nArrayDeque is a fast, array-backed deque implementation for Python written in C. It provides high-performance double-ended queue operations similar to Python’s built-in `collections.deque`, with a straightforward and efficient design.\n\n## Features\n\n- **Fast Operations:** Quick appends and pops at both ends.\n- **Random Access:** Efficient in-place item assignment and index-based access.\n- **Full API Support:** Implements iteration, slicing (via `__getitem__` and `__setitem__`), and common deque methods.\n- **C Extension:** A complete CPython C-extension for optimal speed.\n- **Benchmark Included:** Compare performance with Python’s built-in `collections.deque`.\n\n![alt text](https://github.com/grantjenks/python-arraydeque/blob/main/plot.png?raw=true)\n\n## Installation\n\nThere are two ways to install ArrayDeque.\n\n### Via PyPI\n\nPre-built wheels are available on PyPI. Simply run:\n\n```bash\npip install arraydeque\n```\n\n### Building from Source\n\nClone the repository and install in editable mode to compile the C-extension:\n\n```bash\ngit clone https://github.com/yourusername/arraydeque.git\ncd arraydeque\npip install -e .\n```\n\n## Usage\n\nOnce installed, use ArrayDeque just like the standard deque:\n\n```python\nfrom arraydeque import ArrayDeque\n\n# Create an ArrayDeque instance\ndq = ArrayDeque()\n\n# Append items on the right\ndq.append(10)\ndq.append(20)\n\n# Append items on the left\ndq.appendleft(5)\n\n# Access by index\nprint(dq[0])  # Output: 5\n\n# Pop items\nprint(dq.pop())     # Output: 20\nprint(dq.popleft()) # Output: 5\n```\n\nArrayDeque supports the standard deque API including methods like `extend`, `extendleft` (which reverses the input order), `clear`, and iteration.\n\n## Benchmarking\n\nA benchmark script ([benchmark.py](benchmark.py)) is provided to compare the performance of ArrayDeque with `collections.deque`.\n\nThe benchmark tests various operations such as append, appendleft, pop, popleft, random access, and a mixed workload. Each operation is run 5 times, with the median time reported.\n\nAfter running the benchmark with:\n\n```bash\npython benchmark.py\n```\n\na plot (`plot.png`) is generated that visually compares the two implementations using a fivethirtyeight-style bar chart.\n\n## Testing\n\nTests are implemented using Python’s built-in `unittest` framework. Run the test suite with:\n\n```bash\npython test_arraydeque.py\n```\n\nAlternatively, if you’re using [tox](https://tox.readthedocs.io/), simply run:\n\n```bash\ntox\n```\n\n## Continuous Integration\n\nThis project uses GitHub Actions for continuous integration. It includes three workflows:\n\n- **Release Workflow (`.github/workflows/release.yml`):** Builds wheels for Ubuntu, macOS, and Windows, then publishes to PyPI.\n- **Test Workflow (`.github/workflows/test.yml`):** Runs the test suite across multiple Python versions.\n- **tox Configuration (`tox.ini`):** Defines test, lint, and formatting environments (using [ruff](https://beta.ruff.rs/)).\n\n## Development\n\nTo set up a development environment:\n\n1. **Clone the repository:**\n\n   ```bash\n   git clone https://github.com/yourusername/arraydeque.git\n   cd arraydeque\n   ```\n\n2. **Create a virtual environment:**\n\n   On Unix/macOS:\n   ```bash\n   python -m venv env\n   source env/bin/activate\n   ```\n   On Windows:\n   ```bash\n   python -m venv env\n   env\\Scripts\\activate\n   ```\n\n3. **Install development dependencies:**\n\n   ```bash\n   pip install tox\n   ```\n\n4. **Format and lint the code:**\n\n   ```bash\n   tox -e format\n   tox -e lint\n   ```\n\n## License\n\nThis project is distributed under the Apache License 2.0.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrantjenks%2Fpython-arraydeque","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrantjenks%2Fpython-arraydeque","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrantjenks%2Fpython-arraydeque/lists"}